pan-users
[Top][All Lists]
Advanced

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

Re: [Pan-users] Latest HOTFIX commit fails to compile


From: Zan Lynx
Subject: Re: [Pan-users] Latest HOTFIX commit fails to compile
Date: Fri, 18 Jan 2013 12:00:31 -0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 1/16/2013 7:09 PM, walt wrote:
> 
> 
> On 01/16/2013 10:22 AM, Zan Lynx wrote:
>> I haven't looked at this code
> 
> I've looked at little else for the last two days while trying to understand 
> it :)
> I'm just an amateur programmer but I've done small projects with several other
> programming languages, but c++ makes me feel completely stupid and I *hate* 
> that :(
>  
>> Using "static" on a global variable in a .h file can result in
>> independent unlinked copies in each .c or .cpp file that uses it.
>> "static" at file scope means that variable exists only for that one
>> file.
> 
> You say "can result", not "will result".  Does the actual result depend on the
> definition of the c++ language itself, or at the discretion of the compiler
> writers?  Do you think the "average" c++ programmer knows the answer to this
> question?  I'm thinking probably not, but I'm happy to be corrected if I'm
> wrong.  I've set out to understand c++ at least four times over the years
> and I've quit trying just as many times.  I think this is my fifth try and
> I haven't given up yet.....

As far as I know, it will always result in independent copies of the
static variable.

However there are some build scripts like what KDE uses that smush all
the C++ files together into one large file, in order to achieve
inter-module optimization. These days GCC has the LTO flag and the file
smashing isn't needed but that is still fairly new.

When all the files are smashed together I believe that you would get
only one static variable defined, because the header files should have
include guards which would include it only one time for all of the
source files.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]