Andes Workshop

It is currently Thu Mar 28, 2024 6:14 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: gcc -D變數
PostPosted: Fri Mar 01, 2013 3:54 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
舉個例子:
nds32le-elf-gcc -O3 -c -DUSR_ENTRY=0x80000 ...(後面不重要,省略)

類似於#define。
在main.c裡有一個 user_pc = (unsigned long)USR_ENTRY;
我們將這個變數的define寫在makefile裡。

下面是gcc對-D的說明。
-D name=definition
The contents of definition are tokenized and processed as if they appeared during
translation phase three in a ‘#define’ directive. In particular, the definition
will be truncated by embedded newline characters.
If you are invoking the preprocessor from a shell or shell-like program you may
need to use the shell’s quoting syntax to protect characters such as spaces that
have a meaning in the shell syntax.
If you wish to define a function-like macro on the command line, write its
argument list with surrounding parentheses before the equals sign (if any).
Parentheses are meaningful to most shells, so you will need to quote the option.
With sh and csh, ‘-D’name(args...)=definition’’ works.
‘-D’ and ‘-U’ options are processed in the order they are given on the command
line. All ‘-imacros file’ and ‘-include file’ options are processed after all
‘-D’ and ‘-U’ options.


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group