I am writing a library for numerical computations. The whole thing is written in C++. However, there are some interesting open source programs I would like to integrate with my library. For example Triangle mesh generator. For the problem lets say I have three files:
TypesAndDefines.h (Ansi C++ syntax)
Triangle.h (Ansi C syntax)
Triangle.c (Ansi C syntax) - souce file for Triangle.h
In general using c files from c++ program works fine, but what I tend to do is:
- I have abstract data types in C++ file TypesAndDefines.h setting for example:
#ifdef x64
typedef double REAL;
#elif
typedef float REAL;
#endif
- there are also namsespaces defined in this file
- I need in Triangle.h and Triangle.c those defined typedefs, but I cannot include it in C-syntax file.
The only working solution I have found is to make a C syntax compatibile version of TypesAndDefines.h file and include it.
However it would be better for the project to use only one file with definitions. Is there any good way to do this? I can of course cancel the C++ TypesAndDefines.h file but then I also cancel using general namespace for my library what is quite elegant and convinient for end user of the lib.
Thanks in advance and regards,
Misery