Re: how to send variable values from Makefile?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 20, 2005 at 03:40:08PM +0800, qiang zeng wrote:
> what i intend to do is that i have a variable in my c program,
> while i am trying to send it a value i get (e.g., an address )when
> executing the makefile.
> so is that possible ?

Easy:

/* mytest.c */
#include <stdio.h>

int main(int argc, char *argv[])
{
	printf("MYVAL = %d\n", MYVAL);
	return 0;
}


And in the Makefile:


CFLAGS=-Wall -O2 -DMYVAL=42

all: mytest


Run "make", run "./mytest" and voila:

MYVAL = 42


Erik

-- 
Erik Mouw
J.A.K.Mouw@xxxxxxxxxxxxxx  mouw@xxxxxxxxxxxx

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux