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. Advertisements

  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. Advertisements

  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. Advertisements

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Wildbill

    Please define slipstreamed

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

    Zigbee: Define "Open" Standard

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

    How to define task in RTOS

    ckto, Jul 21, 2005, in forum: Embedded
    Replies:
    7
    Views:
    797
    Ian Bell
    Jul 22, 2005
  4. ElderUberGeek
    Replies:
    3
    Views:
    371
    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:
    476
    Morten M. Jørgensen
    Aug 2, 2006
  6. The Real Andy

    Embeddded programming, define embedded.

    The Real Andy, Nov 29, 2006, in forum: Embedded
    Replies:
    25
    Views:
    625
    Paul E. Bennett
    Dec 4, 2006
  7. Richard Pennington

    A new way to define systems of systems?

    Richard Pennington, Apr 7, 2007, in forum: Embedded
    Replies:
    17
    Views:
    639
    Richard Pennington
    Apr 12, 2007
  8. Martin Trautmann

    OSX finder: define private date format

    Martin Trautmann, Jul 21, 2004, in forum: Apple
    Replies:
    1
    Views:
    407
    Wayne C. Morris
    Jul 21, 2004
Loading...