1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

header file define in make file

Discussion in 'Embedded' started by sentil@gmail.com, Feb 12, 2007.

  1. Guest

    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.
     
    , Feb 12, 2007
    #1
    1. Advertising

  2. Arlet Guest

    On Feb 12, 10:52 pm, 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.
     
    Arlet, Feb 12, 2007
    #2
    1. Advertising

  3. Dave Hansen Guest

    On Feb 12, 3:52 pm, 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
     
    Dave Hansen, Feb 12, 2007
    #3
  4. 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.
     
    Hans-Bernhard Bröker, Feb 14, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wildbill

    Please define slipstreamed

    Wildbill, Apr 21, 2004, in forum: Asus
    Replies:
    4
    Views:
    281
  2. myren, lord

    Zigbee: Define "Open" Standard

    myren, lord, Jan 12, 2005, in forum: Embedded
    Replies:
    5
    Views:
    761
    myren, lord
    Jan 13, 2005
  3. ckto

    How to define task in RTOS

    ckto, Jul 21, 2005, in forum: Embedded
    Replies:
    7
    Views:
    662
    Ian Bell
    Jul 22, 2005
  4. ElderUberGeek
    Replies:
    3
    Views:
    271
    Dave Hansen
    Feb 14, 2006
  5. Morten M. Jørgensen

    How to define placement address of functions?

    Morten M. Jørgensen, Aug 1, 2006, in forum: Embedded
    Replies:
    4
    Views:
    359
    Morten M. Jørgensen
    Aug 2, 2006
Loading...

Share This Page