Motherboard Forums


Reply
Thread Tools Display Modes

header file define in make file

 
 
sentil@gmail.com
Guest
Posts: n/a
 
      02-12-2007, 09:52 PM
Hi all,

I am using cosmic compiler for software development. Now, I am just
curious whether can I do the following...

In make file
Define label GLOBAL_PATH = $(BASE)\control\global.h

Then used GLOBAL_PATH everywhere in header files

#include GLOBAL_PATH
instead of
#include "..\control\global.h"

Let me know you two cents.
Thanks.

 
Reply With Quote
 
 
 
 
Arlet
Guest
Posts: n/a
 
      02-12-2007, 10:20 PM
On Feb 12, 10:52 pm, (E-Mail Removed) wrote:
> Hi all,
>
> I am using cosmic compiler for software development. Now, I am just
> curious whether can I do the following...
>
> In make file
> Define label GLOBAL_PATH = $(BASE)\control\global.h
>
> Then used GLOBAL_PATH everywhere in header files
>
> #include GLOBAL_PATH
> instead of
> #include "..\control\global.h"
>
> Let me know you two cents.
> Thanks.


Variables defined in makefiles aren't generally exported to the
compiler, but they have to be explicitly provided as command line
options added to the compiler flags. On most compiler this is done
with a '-D' flag. Consult your compiler documentation to be sure.

In addition, you must provide escaped quotes around the filename.

So define:

GLOBAL_PATH = \"$(BASE)\control\global.h\"

and call your compiler with -D option

$(CC) -DGLOBAL_PATH=$(GLOBAL_PATH)

Or add it to the CFLAGS variable.

 
Reply With Quote
 
 
 
 
Dave Hansen
Guest
Posts: n/a
 
      02-12-2007, 10:22 PM
On Feb 12, 3:52 pm, (E-Mail Removed) wrote:
> Hi all,
>
> I am using cosmic compiler for software development. Now, I am just
> curious whether can I do the following...
>
> In make file
> Define label GLOBAL_PATH = $(BASE)\control\global.h
>
> Then used GLOBAL_PATH everywhere in header files
>
> #include GLOBAL_PATH
> instead of
> #include "..\control\global.h"


It's been a while since I used Cosmic. But the short answer is (I
believe) "Yes."

You will have to add an option to the CFLAGS in your makefile.
Something like -DGLOBAL_PATH=$(GLOBAL_PATH).

HTH,

-=Dave

 
Reply With Quote
 
Hans-Bernhard Br÷ker
Guest
Posts: n/a
 
      02-14-2007, 11:39 PM
(E-Mail Removed) wrote:

> I am using cosmic compiler for software development. Now, I am just
> curious whether can I do the following...


Not as written, but it's possible to do something very much like it.
See the other replies for details.

BUT:

> #include GLOBAL_PATH
> instead of
> #include "..\control\global.h"


neither of these really is a good idea. Don't put path names in
#include statements. Not from the outside (like GLOBAL_PATH), nor from
inside the source file itself. Use your compiler's method of specifying
include file search paths from outside the source, instead. It's
usually the -I option.

And if you choose to ignore this advice and put path names into your C
source, you _definitely_ don't want to spell them with single
backslashes. Use forward slashes (they work on DOS/Windows, too!), or
double them up.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to define placement address of functions? Morten M. J°rgensen Embedded 4 08-02-2006 11:48 AM
How to define a good protocol (not just the messages)? ElderUberGeek Embedded 3 02-14-2006 03:04 PM
How to define task in RTOS ckto Embedded 7 07-22-2005 11:55 AM
Zigbee: Define "Open" Standard myren, lord Embedded 5 01-13-2005 10:05 PM
Please define slipstreamed Wildbill Asus 4 04-26-2004 03:45 PM


All times are GMT. The time now is 05:44 AM.


Welcome!
Welcome to Motherboard Point
 

Advertisment