[Nut-upsdev] [nut-commits] svn commit r2845 - branches/windows_port/common

Arjen de Korte nut+devel at de-korte.org
Wed Jan 19 10:54:56 UTC 2011


Citeren Frédéric Bohé <fredericbohe op eaton.com>:

> Thanks for the clarification.
> I just tried to compile and I have an error on this line, not sure how
> to fix that.
>
> common.c: In function 'confpath':
> common.c:443:2: error: initializer element is not constant
> common.c: In function 'dflt_statepath':
> common.c:454:2: error: initializer element is not constant

I stand corrected. In order for this to work, the initializer must be  
known at compile time (it should be a constant, since it is filled in  
by the compiler and not at runtime). So instead of

     static const char *path = getfullpath(PATH_ETC);

this should be split in

     static const char *path = NULL;
     if (path == NULL) {
         path = getfullpath(PATH_ETC);
     }

This will assign 'NULL' to 'path' at compile time and at runtime, will  
try to read the path as long as it stays 'NULL'. This means that it  
will only be assigned a value the first time this is executed.

Best regards, Arjen
-- 
Please keep list traffic on the list (off-list replies will be rejected)




More information about the Nut-upsdev mailing list