Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a tool to add the "override" identifier to existing C++ code
    primarykey
    data
    text
    <h1>The task</h1> <p>I am trying to work out how best to add C++0x's <a href="http://en.wikipedia.org/wiki/C++0x#Explicit_overrides_and_final"><code>override</code></a> identifier to all existing methods that are already overrides in a large body of C++ code, without doing it manually.</p> <p>(We have many, many hundreds of thousands of lines of code, and doing it manually would be a complete non-starter.)</p> <h1>Current idea</h1> <p>Our coding standards say that we should add the <code>virtual</code> keyword against all implicitly virtual methods in derived classes, even though strictly unnecessary (to aid comprehension).</p> <p>So if I were to script the addition myself, I'd write a script that read all our headers, found all functions beginning with virtual, and insert <code>override</code> before the following semi-colon. Then compile it on a compiler that supports <code>override</code>, and fix all the errors in base classes.</p> <p>But I'd really much rather not use this home-grown way, as:</p> <ul> <li>it's obviously going to be tedious and error-prone.</li> <li>not everyone has remembered, every time, to add the virtual keyword, so this method would miss out some existing overrides</li> </ul> <h1>Is there an existing tool?</h1> <p>So, is there already a tool that parses C++ code, detects existing methods that overrides, and appends <code>override</code> to their declarations?</p> <p>(I am aware of static analysis tools such as <a href="http://www.gimpel.com/html/index.htm">PC-lint</a> that warn about functions that look like they should be overrides. What I'm after is something that would actually munge our code, so that future errors in overrides will be detected at compiler-time, rather than later on in static analysis)</p> <p>(In case anyone is tempted to point out that C++03 doesn't support 'override'... In practice, I'd be adding a macro, rather than the actual "override" identifier, to use our code on older compilers that don't support this feature. So after the identifier was added, I'd run a separate script to replace it with whatever macro we're going to use...)</p> <p>Thanks in advance...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload