• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: environment variables during compile time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: environment variables during compile time


  • Subject: Re: environment variables during compile time
  • From: Marco S Hyman <email@hidden>
  • Date: Wed, 13 Jul 2011 09:11:19 -0700

On Jul 13, 2011, at 5:38 AM, Vyacheslav Karamov wrote:

> man getenv

He wants them at COMPILE time.  getenv won't help unless he modifies
the compiler to use it. :)

In general, the compiler can define values on the command line.
It can get the values from the environment.

test.c:
#include "stdio.h"

int main(int argc, char *argv[])
{
 printf("FOO has a value of %s\n", FOO);
}

command line:
  export bar='"this is bar"'
  gcc -D"FOO=$bar" test.c

Output after compiling:
  ./a.out
  FOO has a value of this is bar

I'll let the OP figure out how to do this in Xcode

/\/\arc

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >environment variables during compile time (From: Jankoen de Haan <email@hidden>)
 >Re: environment variables during compile time (From: Vyacheslav Karamov <email@hidden>)

  • Prev by Date: Re: environment variables during compile time
  • Next by Date: Non-executable build products?
  • Previous by thread: Re: environment variables during compile time
  • Next by thread: Non-executable build products?
  • Index(es):
    • Date
    • Thread