Hi, I need help with a little problem.
As a source I wrote overloaded func in another source file. Linked to .h and I need to create a macro that runs one of the functions.
Main source
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include "another.h"
long a;
#ifdef F1
#define macro() func_in_another(a) // problem - func alredy defined
#else
#define macro() func_in_another() // same problem
#endif
int main(array<System::String ^> ^args) {
...
macro();
...
}
Another source
1 2 3 4 5 6 7
func_in_another(long a) {
...
}
func_in_another() {
...
}
OpenGL libraries do things like the above, I think. Though I do not suggest it, because it can make compiler errors must more nasty because you're defining macros.
Or are you saying you want a to be a default argument? Give us more information, it would be better if we knew what the original problem is, and not what you think is an appropriate solution that doesn't work.
That's fine but one is called with a parameter and the other is called without, in the main code I will have to go around and I would rather use one name without parameters to call one or the other with the parameter (param is statically given). And yes, site is slow :-D
#define OS_A
#if defined (OS_A)
void func(long a, long b)
{
}
void func()
{
func(42, 43);
}
#elif defined (OS_B)
void func(char ch)
{
}
void func()
{
func('h');
}
#else
#error No OS defined
#endif
int main()
{
func();
}