i'm studying about arduino but i want to test my code by g++ compiler before adjust to arduino.
it is easy way to test if i make two same code but it makes me tiresome.
so i want to do conditional compile.
here is my code
CustomMath.cpp
#include "CustomMath.h"
#if defined(_CPP_)
#include <cmath>
#endif
#if defined(_ARDUINO_)
#include "math.h"
#endif
float CustomMath::cSin(int degree)
{
float value = 2;//check for this code is work right
float radian = cDegreeToRadian(degree);
#if defined(_CPP_)
value = sin(radian);
#elif defined(_ARDUINO_)
value = sin(radian);
#endif
return value;
}
and here is main code
#define _CPP_
#include <iostream>
#include "CustomMath.h"
using namespace std;
using namespace CustomMath;//CustomMath.h ic braced by namespace CustomMath
int main()
{
cout << "sin : " << cSin(30) << endl;
}
and output is
sin : 2 <<-- this means conditional compile is not work
i think _CPP__ is defined after CustomMath compiled. how can i do conditial compile? or is there something wrong?
==========================================================================
i just add ComileCondition.h
#define _CPP_
and i just change this part when i adjust on arduino