Shop OBEX P1 Docs P2 Docs Learn Events
#ifdef Question/problem — Parallax Forums

#ifdef Question/problem

cmeehancmeehan Posts: 8
edited 2013-11-22 18:56 in Propeller 1
I am trying, and failing to figure out the #define statements. Here is the code I am using.

ifndef-Test.h

#ifndef _TEST1_
#define _TEST1_ 1
#endif

//#define _DEBUG_ 1


ifndef-Test.c

#include "simpletools.h"

int main(void){

#ifdef _TEST1_
print("_TEST1_ is defined\n");
#endif

#ifdef _DEBUG_
print("_DEBUG_ is defined\n");
#endif

return 0;
}

I expect the header file to define _TEST1_ because it is not defined, and it the main I expect the print statement to execute.
The #define _DEBUG_ 1 is commented out so the print statement should not execute.

The goal is to easily turn debug print statements on and off.

Am I missing something simple?

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2013-11-22 16:32
    If you want your ifndef-Test.c to know about _TEST1_ then you have to include the ifndef-Test.h file.
    ...
    #include "simpletools.h"
    #include "ifndef-Test.h"
    ...
    
  • cmeehancmeehan Posts: 8
    edited 2013-11-22 18:56
    Thanks, that was it.
Sign In or Register to comment.