Making Inline Functions Compatible With C Compilers

Making Inline Functions Compatible With C Compilers

A global function may be declared inline. If you use the same function in different development environments, e.g., C and C++, you can hide the “inline” keyword from a C compiler while keeping it visible to a C++ compiler like this:

 #ifndef __cplusplus#define inline#endif

The preprocessor directives make sure that only a C++ compiler sees the inline keyword:

 inline int get_dst() {return dst; }// inline not seen by C

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist