Compile-time options - General Discussion and Assistance - CHDK Forum

Compile-time options

  • 3 Replies
  • 1578 Views
Compile-time options
« on: 21 / March / 2010, 20:01:57 »
Advertisements
In buidconf.c, I have added MOVIE_SYNCH=1 (not commented-out).
In makefile.inc, I have include $(topdir)buildconf.inc  (though after the other includes).

In the code I have #if defined (MOVIE_SYNCH) or #ifdef MOVIE_SYNCH.

As absolutely nothing happens, it seems the code is not included in the compilation.

If I comment-out the MOVIE_SYNCH defines the code works.

Any ideas why ?

*

Offline reyalp

  • ******
  • 12537
Re: Compile-time options
« Reply #1 on: 22 / March / 2010, 05:07:49 »
First, you mean buildconf.inc right, not buidconf.c ?

If you want MOVIE_SYNCH to be passed to the compiler, you need to add it to cflags somewhere, otherwise it's just a makefile variable. CHDK does it like this
Code: [Select]
ifdef OPT_GAME_REVERSI
CFLAGS+=-DOPT_GAME_REVERSI
OPT_OBJS+=gui_reversi.o
endif
(you don't need the .o stuff if there isn't a .c file which is only used by your feature)
Don't forget what the H stands for.

Re: Compile-time options
« Reply #2 on: 22 / March / 2010, 07:40:46 »
Thanks, that works.

so, -D  defines makefile variable OPT_GAMES_REVERSI as a macro with value 1 ?

*

Offline reyalp

  • ******
  • 12537
Re: Compile-time options
« Reply #3 on: 23 / March / 2010, 18:21:21 »
so, -D  defines makefile variable OPT_GAMES_REVERSI as a macro with value 1 ?
It just makes it defined.  See http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options and http://gcc.gnu.org/onlinedocs/cpp/

Use -DNAME=VALUE if you want to give it a specific value.

If you want to define VALUE just once in the makefile, you'd want to do something like -DNAME=$(NAME), assuming your makefile variable and pre-processor macro have the same name.
Don't forget what the H stands for.


 

Related Topics