[RESOLVED] #define not working between includes
I have the following code on my main.cpp:
Code:
#ifdef _WIN64
#define hOS 1
#elif _WIN32
#define hOS 1
#elif __APPLE__
#define hOS 2
#elif __linux
#define hOS 3
#else
#define hOS 0
#endif
#include "functions.h"
functions.h:
Code:
#ifndef _FunctionsFile
#define _FunctionsFile
#include <string.h>
#include <iostream>
using namespace std;
void someFunction(bool someParameter);
#endif
functions.cpp:
Code:
#include "functions.h"
void someFunction(bool someParameter= false)
{
if (hOS==1)
{
std::cout<<"Windows";
}
}
When trying to complile I get this error in functions.cpp:
C:\Dev\CPP\functions.cpp `hOS' undeclared (first use this function)
Re: #define not working between includes
Hey
its a long long time that i didnt use c++:D but as far as i remember #include MOST always be the first thing that u are writing then define
Re: #define not working between includes
Hey monk,
Thanks for the reply! It seems you must #define on every page that wants it, it, including a page doesn't carry over its defines. All fixed though =).