New parameter in GCC
Harry Trinta
harrytpc@gmail.com
Tue Aug 9 05:38:00 GMT 2011
Ian, sorry
I think this option (-D) can be useful. But I did not understand how
to use this option .
You told me to create a new file, but this file is for the GCC or for
the program being compiled?
Using the -D option, I can access the IP address within the compiled
program or just during compilation?
Thank you for your attention
Harry
2011/8/5 Ian Lance Taylor <iant@google.com>:
> Harry Trinta <harrytpc@gmail.com> writes:
>
>> I'm developing a mechanism in the gcov, instead of writing the file
>> gcda (in file gcov-io.c), it sends the information to a host via a
>> socket. The host generates gcda.
>>
>> So I'd like to get the IP at compile time to use when sending the data
>> through the socket.
>>
>> But from what you said, the variable is only available at compile
>> time, which is not my case.
>>
>>> To be clear, this will give you a new variable in the compiler itself.
>>> It will not give you a variable in the gcov program, nor in the program
>>> you are compiling. You will have to figure out some mechanism to get
>>> the value to the point where you need it. It's not clear to me where
>>> that point is.
>>
>> What kinds of mechanisms I can develop to use this variable when
>> sending information?
>
> There are many ways to get an IP address defined at compile time into
> the gcov library. Most of them do not involve changing the compiler
> proper at all (you do of course have to change the gcov support
> library).
>
> Making this a compile time option seems odd. What should happen if you
> link together two different files compiled with different values for the
> option? What you really want is to make a link time option.
>
> Suppose you just change the gcov library to look for a global variable
> gcov_ip_address. Then create a tiny file
>
> const char* gcov_ip_address = GCOV_IP_ADDRESS
>
> Then compile that file with -DGCOV_IP_ADDRESS=nn.nn.nn.nn.
>
> That approach is much simpler than changing the compiler proper. What
> do you need that you can't get from that?
>
> Ian
>
More information about the Gcc-help
mailing list