You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building C applications using the dwfsdk. This library has a single header file to import (convenient) which contains both function declarations and configuration/enum constants. When I have a single file including "dwf.h", there is no issue. But when I include this file in multiple source files (i.e. a driver wrapper), GCC complains about multiple declarations of the the 197 "const" entries contained within "dwf.h".
I think the correct way to solve this is to replace the consts with typedef enum, as in:
// analog acquisition filter:typedefintFILTER;
constFILTERfilterDecimate=0;
constFILTERfilterAverage=1;
constFILTERfilterMinMax=2;
There are a few instances where such a replacement is not quite appropriate, in which case a macro definition is a potential solution.
I'm attaching a version of "dwf.h" which implements this solution (but since github doesn't allow attaching .h files, I have changed
the extension to .txt). dwf.txt
I have not tested every function in the library (in fact have only tested a few), but it compiles while avoiding multiple definitions and seems to work so far. I have added a few "TODO" comments to highlight potential type conflicts if used with a compiler that doesn't allow implicit type conversion. These can be solved with macro definitions as well if they turn out to cause issues.
The text was updated successfully, but these errors were encountered:
I'm building C applications using the dwfsdk. This library has a single header file to import (convenient) which contains both function declarations and configuration/enum constants. When I have a single file including "dwf.h", there is no issue. But when I include this file in multiple source files (i.e. a driver wrapper), GCC complains about multiple declarations of the the 197 "const" entries contained within "dwf.h".
I think the correct way to solve this is to replace the consts with typedef enum, as in:
can be converted to:
There are a few instances where such a replacement is not quite appropriate, in which case a macro definition is a potential solution.
I'm attaching a version of "dwf.h" which implements this solution (but since github doesn't allow attaching .h files, I have changed
the extension to .txt).
dwf.txt
I have not tested every function in the library (in fact have only tested a few), but it compiles while avoiding multiple definitions and seems to work so far. I have added a few "TODO" comments to highlight potential type conflicts if used with a compiler that doesn't allow implicit type conversion. These can be solved with macro definitions as well if they turn out to cause issues.
The text was updated successfully, but these errors were encountered: