This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New parameter in GCC


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]