Citeren Frédéric Bohé <[email protected]>:

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)


_______________________________________________
Nut-upsdev mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev

Reply via email to