User forums > Using Code::Blocks

Setting #define for project (not in Source Code)

(1/3) > >>

duderino65:
Hello,

I'm Andi from Germany. I currently developing for STM32 and recently switched from Windows to Linux and made up a new environment on my Linux Host.
I use an Keil ARMCC for Linux and a Makefile with 2 targets (CPU1 & CPU2). Building from Makefile works fine.
My little problem now is, that I define FIRMWARE_CPU1 or FIRMWARE_CPU2 in my Makefile depending on the target I'm building. But Codeblocks doesn't know that and does not see any FIRMWARE_xxx define in Source Code.

How can I setup a difine which is just valid for my project? As I'm developing on a device with 2 Mikrocontrollers I also have 2 Codeblocks Projects. So each of this projects need its own FIRMWARE_CPU define. Is this possible?

P.S.: I've experienced, that a configuration in Settings->Compiler->.... is alway for Codeblocks itself. Not just for the project... So this would be no solution, I think.

Thanks and kind regards
Andi

Miguel Gimenez:
Try under Project -> Build options,  inside tab Compiler settings select tab #defines

duderino65:
Hi,
thanks for reply. Unfortunately I don't have a #define-Menu in my Build Options. This #define Menu I only have in Settings->Compiler. But as already said, this Menu is for Codeblocks in general, not only for a particular project.
I attached my Build Options Menu as I see it and my actual Codeblocks About Menu.

Can I define it in these Variables Tab?

Kind regards
Andi

stahta01:
PLEASE always state when you are using an CB Custom makefile project instead of a normal CB Project!

Edit: The options are missing because they are ignored by an CB Custom makefile project.

You need to read up on how makefiles work and then look at the makefile.

You will likely need to edit the makefile; but, the best answer make be to pass an option to the makefile.

Tim S.

duderino65:
Hi,

sorry, I mentioned that I use a Makefile and with that I also checked the 'This is a custom Makefile' in my Projects Options. So when I hit the Build Icon my Makefile is running.
Even if I don't have much experience with Makefiles, I created this Makefile by my own and I know how it normally works. As I use this Makefile also for CI Builds I don't want to change it and I don't see a need to change it.

From my point of view it is just a markup problem from the IDE because it does not see this Define (not a Bug!). So my idea was, if possible, just to do a #define somewhere in the project settings. I want my Makefile to be completely independent from any IDEs.

I hope this is somehow possible.

Kind regards
Andi

Navigation

[0] Message Index

[#] Next page

Go to full version