How to Define Predefined Macros in SPRESENSE

Asked 2 years ago, Updated 2 years ago, 337 views

I'd like to divide the process by predefined macros with compiler options as shown below.

#ifdef HOGE
  Processing 1
# else
  Processing 2
#endif

What should I do with SPRESENSE IDE?
I looked around the SDK configuration, but I couldn't find it.
Can someone please teach me?

■Environment
PC: Ubuntu 18.04.4 LTS
SDK: v2.0.1
IDE:v1.2.0

spresense

2022-09-30 21:51

2 Answers

The Sony Spresense SDK seems to use an orthodox Makefile.

The general notation for Makefile is that there are many sources of information on the web, so please look at them.
If you want to define a macro constant symbol for C named HOGE, pass it to the C compiler by adding the -D option to CFLAGS in the Makefile.

CFLAGS+=-DHOGE


2022-09-30 21:51

It's not a stress, it's a C language problem.

Typically, you create such a header file and write the macro for the compilation switch in it.

Another way is to define each macro with the compilation options


2022-09-30 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.