I was just wondering whether the C++ preprocessor is capable of macros such as:
#define include<a> include<a.h>
Which would convert
#include<stdio>
into
#include<stdio.h>
Does anyone have any ideas?
I was just wondering whether the C++ preprocessor is capable of macros such as:
#define include<a> include<a.h>
Which would convert
#include<stdio>
into
#include<stdio.h>
Does anyone have any ideas?
The #include
directives can't be replaced directly with a macro. However, the entity to be included can be the result of a macro expansion. That is, if you need to use different header names, you can define a macro which expands to what is being included, e.g.:
#define CONCAT(a,b) a ## b
#ifdef USE_C_NAMES
# define MAKE_NAME(x) <x.h>
#else
# define MAKE_NAME(x) <CONCAT(c,x)>
#endif
#include MAKE_NAME(stdio)