devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  How Seasoned Architects Evaluate New Tech

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.