acassen / keepalived

Keepalived
https://www.keepalived.org
GNU General Public License v2.0
4.02k stars 736 forks source link

executing ''make && make install' error #2476

Closed orzming closed 1 month ago

orzming commented 1 month ago

Keepalived version : 2.3.1 Linux version : RedHat 7.9 gcc version : 4.85

Additional context I install the keepalived by source code(tar.gz file),but there are some errors when executing ''make && make install': 9c0eade13f3f526ace4d9401f4dd57db_ 8d84f8ab33cde10666aa2da1340879a6_

how to solve it?thank you for your help!

pqarmitage commented 1 month ago

I would suggest that you have a problem with your compiler. The error message you are getting is quite clearly nonsense; there is no way that NULL is not constant.

I have just compiled keepalived v2.3.1 on RHEL 7.9 with gcc 4.8.5 and I don't get the error that you are experiencing. To be precise the version of gcc is: gcc version 4.8.5 20150623 (RedHat 4.8.5-44) (GCC)

You could try changing the definition of RB_ROOT to be: #define RB_ROOT (struct rb_root) { NULL } i.e. remove the comma (,), but I am merely guessing because, as I said, the error is nonsense.

The C standard says that if any field of a structure is initialized, then any unspecified fields are set to 0, and the compiler is not adhering to that (see the warning for keepalived_netlink.c line 1531):

C99 Standard 6.7.8.21

    If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.
pqarmitage commented 1 month ago

If the above idea doesn't work, you could simply change static rb_root_t process_tree = RB_ROOT; to static rb_root_t process_tree;

A static variable/struct is initialised to NULL or 0 values, so it will have the same effect, but is not explicitly initialising process_tree via the proper definition for that purpose.