I know how to use __attribute__((deprecated))
or [[deprecated]]
to deprecate a function like this:
int old_fn() __attribute__ ((deprecated));
[[deprecated]] int old_fn2();
But how to deprecate a Macro like this:
#define OLD_MACRO 1
4. Which gcc option undefines a preprocessor macro? Explanation: None.
Note that __SIZE_TYPE__ isn't a variable; it's a type. Compilers other than GCC probably do not provide it, unless they're trying to be compatible with GCC. If you want size_t , include <stddef. h> if you aren't including any of the other headers (such as <stdio. h> , <string.
__COUNTER__ is a preprocessor macro available in most compilers that expands to sequential integers starting from zero. It resets at the beginning of each new translation unit (i.e. each object file), and is commonly used with the paste ( ## ) operator to create unique identifiers within other macros.
The C preprocessor implements the macro language used to transform C, C++, and Objective-C programs before they are compiled. It can also be useful on its own.
Nice, elegant solution, however depending on C99 being enabled (works with gcc 4.8.2 or later, not tested on earlier versions):
#define DEPRECATED_MACRO1 _Pragma ("GCC warning \"'DEPRECATED_MACRO1' macro is deprecated\"") 7
#define DEPRECATED_MACRO2(...) _Pragma ("GCC warning \"'DEPRECATED_MACRO2' macro is deprecated\"") printf(__VA_ARGS__)
int main(int argc, char*argv[])
{
int n = DEPRECATED_MACRO1;
DEPRECATED_MACRO2("%d\n", n);
return 0;
}
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