10-31-2018 05:20 PM
Hi,
I am looking for a way to have the compiler tack on an include statement for a global header file, the equivalent of manually putting #include "some_file.h" in all of my source files, which I don't want to do since this code is common and used among a log of projects so I'm trying not to clutter it or change it's source code since it already functions well for all other programs it's used in.
Code repositories which I am inheriting use functions, such as fabsf() and powf(), but it appears I only have access to the double versions: fabs() and pow().
It would make the code too cluttered to surround all uses of the math function variants which I don't have access too to use the other version:
#if defined(_THEIR_CODE_) /*...*/fabsf(some_variable)/*...*/ #elif defined(_MY_CODE_) /*...*/fabs(some_variable)/*...*/ #endif
Instead, I have made a file, lets call it compatibility.h, which includes macros which define these to use the double version:
#define atan2f(arg, args...) atan2(arg, #args) #define sqrtf(arg, args...) sqrt(arg, #args) #define fabsf(arg, args...) fabs(arg, #args) #define powf(arg, args...) pow(arg, #args)
Now again I cannot clutter up the code adding a macro to check if it's my version and then #include "compatibility.h", instead I need to have the compile/build process automatically include this file in all of my source code (referred to as "global include" or "pre include" in other contexts)
From everything I've looked at I have not found a solution to this.
LabWindows CVI 2017 uses Clang 3.3 so I have been also looking to see if there is a command line option I could provide which would allow me to specify a pre/global include but haven't found that either.
Thanks!
11-01-2018 10:26 AM
You need to set compatibility.h as precompiled header in your project. It does exactly what you described