I have to filter out from a huge amount of cpp files all the macros defined, excluding the guards, for example:
#if <NAME>
#ifdef <NAME>
#ifndef <NAME>
#if defined(<NAME>)
#if defined <NAME>
!defined(<NAME>)
!defined <NAME>
#else if <NAME>
#elif <NAME>
I have to retrieve all the NAMEs, but they are not all in the form XXX, due to different programmers working on the project, there are a lot of definitions, so I am facing problems in define a regex that can extract only <NAME> from each of the situations just described.
Any advice is appreciated!
EDIT
As someone pointed out, my NAME (with surrounding angle brackets <>) is only a placeholder, where in reality it can be XXXX, XXXX, XX_Y, _XXX , _XXX_Y, XXYY where X and Y could be uppercase letters or digits, with no regularity in the name! They are directives to the preprocessor and I have to filter them out.
greporawk, depending on what you need to do with the lines that you find.#if defined(A) || defined(B) || (defined(C) && defined D), (which likely needs to list all of A, B, C, and D), and you need to worry about macro conditions being continued over multiple lines with backslashes at the end of each non-continuation line.