Looking for preprocessor command to remove command in code

272 views Asked by At

I am working on a C library which sometimes uses

 static inline void myfunc(...)

when defining a function.

Now I try to port this to an old C compiler that does not support "static inline". This is bcc - Bruce's C compiler.

Can I use a command in a header file that replaces

static inline void

with

void

in all programs that include this header file?

2

There are 2 answers

4
Sergey Kalinichenko On

When you must target a compiler that does not support certain features, it is common to use macros in your code, rather than trying to modify your code with macros.

In this situation you can define STATIC_INLINE macro in a compiler-dependent way, and use it like this:

#ifdef BCC_COMPILER
#define STATIC_INLINE
#else
#define STATIC_INLINE static inline
#endif
...
STATIC_INLINE void myfunc(...)
1
Georg On

Thank you very much to all for the help. I have to report that BLUEPIXY gave the answer that worked for me in his comment:

 #define inline

Apparently bcc does accept static void but not static inline void.