I am developing a library where the size of some variables depends on a #define and some #define which are created depending on the value of other #define.
e.g.
int variable1[SIZE_USER]
#if SIZE_USER>3
#define CONDITION 1
#else
#define CONDITION 0
#endif
The idea is that when a user wants to work with the library they create there own header file with all the preprocessor directives (#define) that are needed and uses this file in the same directory where there "main.cpp" file is and not inside the library source files.
The problem is that when I include the configuration file (which has all the #define's) in the same directory where all my header files of the library are I do not have problems.
i.e.
#include <config.h>
//My Library Code...
But if I declare the configuration header file outside the source files of my Library the compiler doesn't find the #define's that were declared in the "main.cpp" file.
i.e.
#include<config.h>
#include<myLibrary.h>
//User code...
Is there something obvious I am missing on how the compiler is working?
#define SIZE_USER 4
int variable1[SIZE_USER]
#if SIZE_USER > 3
#define CONDITION 1
#else
#define CONDITION 0
#endif
First problem is missing spaces in the #if directive.
#include "myLibrary.h"
Second problem: use "" for your included headers and spaces matter.