Converting projects from Cosmic to CW

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Converting projects from Cosmic to CW

跳至解决方案
2,758 次查看
Bruce_andrew
Contributor I
I'm investigating whether to move from using Cosmic to CW, for the HC08 family.

Cosmic allows the project to include some defines. This is useful where you have several target boards using common code. I have 2 boards that use different MCUs (GP32 & GZ16), as well as internal/external CAN controller.

Is there a simple way to add some defines at project level, so that I don't have to change all the source files. I can't see anywhere in CW how to do this.

I found the info in the helpfile - "Porting from Cosmic", but it doesn't seem to mention anything about defines.

I was hoping that CW would be able to import Cosmic projects, but that doesn't seem possible. Seems to be a lot of work to do so manually for each project.

Any help and suggestions appreciated.
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
635 次查看
BlackNight
NXP Employee
NXP Employee
Hello,
there is the compiler option -D you can use to add your own defines. Something like
-DmyDefine=1
Simply add this to your make file (if you use one) or add it to the compiler options inside CodeWarrior.
The other thing is you could use the option -AddIncl where you can specify a file to be included for every file compiled, something like
-AddIncl=myheader.h

Regards,
Erich

在原帖中查看解决方案

0 项奖励
回复
3 回复数
635 次查看
Bruce_andrew
Contributor I
Thanks for the reply. I'll give that a go.
0 项奖励
回复
635 次查看
Bruce_andrew
Contributor I
I've tried using an include file. It works, but I get some strange error messages.

Looking further, I've found that CW does allow you to use defines. However it's buried in the settings.

Goto Project Settings, Compiler, Language, and then check "preprocessor defines". You can then enter the defines.

IMHO this should be more accessible, but maybe other people don't care for reusing code. We use common source files for multiple projects, so using defines for things like PCB variant, MCU used, etc is VERY handy.

With Cosmic not only can you easily set defines for the project, you can also set defines specific to each source file.
0 项奖励
回复
636 次查看
BlackNight
NXP Employee
NXP Employee
Hello,
there is the compiler option -D you can use to add your own defines. Something like
-DmyDefine=1
Simply add this to your make file (if you use one) or add it to the compiler options inside CodeWarrior.
The other thing is you could use the option -AddIncl where you can specify a file to be included for every file compiled, something like
-AddIncl=myheader.h

Regards,
Erich
0 项奖励
回复