I can't find a setting in eclipse so that I can have it automatically indent my preprocessor macros the same way it indents code. For example eclipse tries to format code like this.
int main()
{
#ifdef SOMETHING
cout << "Something Defined" << endl;
#endif
return 0;
}
Whereas I want it to look like...
int main()
{
#ifdef SOMETHING
cout << "Something Defined" << endl;
#endif
return 0;
}
Any ideas to make eclipse do it how I want?
C static code analysis: Preprocessor directives should not be indented.
Use the Discovery Tab on Build preference panel to define global scanner discovery options. In the Discovery tab you can see a list of Language Settings Providers. Language Settings Providers supply Language Settings such as include paths and preprocessor macros for the indexer and other components of CDT.
Include paths and preprocessor macros for C/C++ indexer and other Language Settings are supplied by Language Settings Providers using Scanner Discovery mechanism. The entries can be inspected and set up on project properties page "Preprocessor Include Paths, Macros, etc." - Entries tab .
Setting Up Include Paths and Macros for C/C++ Indexer 1 Scanner Discovery. ... 2 C/C++ Project properties: Preprocessor Include Paths, Macros, etc. ... 3 Adding and Editing entries. ... 4 C/C++ Project properties: Preprocessor Include Paths, Macros, etc. ...
The C preprocessor is a macro preprocessor (allows you to define macros) that transforms your program before it is compiled. These transformations can be the inclusion of header file, macro expansions etc. All preprocessing directives begin with a # symbol. For example,
Often, include paths are supplied to the compiler with -I options, and macros with -D options. That relies on verbose build output of your build where all these options are actually printed by make. Scanner Discovery uses Language Settings Providers to find include paths and preprocessor symbols.
Pre-ANSI C preprocessor did not allow for space between the start of a line and the "#" character; the leading "#" had to always be placed in the first column.
Pre-ANSI C compilers are non-existent these days. Use which ever style (space before "#" or space between "#" and the identifier) you prefer.
But I suggest you do this:
Just use Find/Replace dialog and the push "Replace all"
I think there is no option for macro indentation. But I see clangformat seems to have option for macro indentation so you can customize your own clang format (http://clang.llvm.org/docs/ClangFormatStyleOptions.html) and configure eclipse to use clangformat instead of the default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With