Trying to build Samba 4.5.5 on a Solaris 10 sparc box using the cc: Sun C 5.13 SunOS_sparc 2014/10/20 compiler.The build fails with the following errors: "../source3/lib/tldap.c", line 2539: non-constant initializer: op "NAME" "../source3/lib/tldap.c", line 2541: non-constant initializer: op "NAME" "../source3/lib/tldap.c", line 2543: non-constant initializer: op "NAME" "../source3/lib/tldap.c", line 2545: non-constant initializer: op "NAME" "../source3/lib/tldap.c", line 2547: non-constant initializer: op "NAME" "../source3/lib/tldap.c", line 2549: non-constant initializer: op "NAME" Only showing the first 6, the rest are the same. The code generating the errors (only the first part) is: static const struct { TLDAPRC rc; const char *string; } tldaprc_errmap[] = { { TLDAP_SUCCESS, "TLDAP_SUCCESS" }, { TLDAP_OPERATIONS_ERROR, "TLDAP_OPERATIONS_ERROR" }, { TLDAP_PROTOCOL_ERROR, "TLDAP_PROTOCOL_ERROR" }, { TLDAP_TIMELIMIT_EXCEEDED, "TLDAP_TIMELIMIT_EXCEEDED" }, { TLDAP_SIZELIMIT_EXCEEDED, "TLDAP_SIZELIMIT_EXCEEDED" }, { TLDAP_COMPARE_FALSE, "TLDAP_COMPARE_FALSE" }, It certainly looks like the initializers are constants. The same code compiles on a Solaris 10 i386 box using the gnu compiler.
I have been looking at this code and I find that I can not understand how it is supposed to work. I asked another person here who is a programmer to look at it and he also does not understand it. We are thinking that this is using some features that are only available in newer C compilers or perhaps only in gcc and our knowledge of C is not quite current. Here is the first part of the revelevent section of source/include/tldap.h. typedef struct { uint8_t rc; } TLDAPRC; #define TLDAP_RC(x) ((TLDAPRC){.rc = x}) #define TLDAP_RC_V(x) ((x).rc) #define TLDAP_RC_EQUAL(x,y) (TLDAP_RC_V(x)==TLDAP_RC_V(y)) #define TLDAP_RC_IS_SUCCESS(x) TLDAP_RC_EQUAL(x,TLDAP_SUCCESS) #define TLDAP_SUCCESS TLDAP_RC(0x00) #define TLDAP_OPERATIONS_ERROR TLDAP_RC(0x01) #define TLDAP_PROTOCOL_ERROR TLDAP_RC(0x02) #define TLDAP_TIMELIMIT_EXCEEDED TLDAP_RC(0x03) #define TLDAP_SIZELIMIT_EXCEEDED TLDAP_RC(0x04) #define TLDAP_COMPARE_FALSE TLDAP_RC(0x05) #define TLDAP_COMPARE_TRUE TLDAP_RC(0x06)
Try adding extra {} braces around the non-string initializers. eg. Change: static const struct { TLDAPRC rc; const char *string; } tldaprc_errmap[] = { { TLDAP_SUCCESS, "TLDAP_SUCCESS" }, ... To: static const struct { TLDAPRC rc; const char *string; } tldaprc_errmap[] = { { {TLDAP_SUCCESS}, "TLDAP_SUCCESS" }, I have a theory about the sun compiler here..
I just tried those changes (57 lines) and I got the same set of error messages.
(In reply to Jeremy Allison from comment #2) For NTSTATUS we have this: #if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct {uint32_t v;} NTSTATUS; #define NT_STATUS(x) ((NTSTATUS) { x }) #define NT_STATUS_V(x) ((x).v) #else typedef uint32_t NTSTATUS; #define NT_STATUS(x) (x) #define NT_STATUS_V(x) (x) #endif I guess we need something similar for TLDAPRC
I patched tldap as follows and it now compiles. --- a/source3/include/tldap.h Thu Aug 11 03:51:04 2016 +++ b/source3/include/tldap.h Fri Mar 10 14:00:04 2017 @@ -47,9 +47,15 @@ DATA_BLOB *values; }; +#if defined(HAVE_IMMEDIATE_STRUCTURES) typedef struct { uint8_t rc; } TLDAPRC; #define TLDAP_RC(x) ((TLDAPRC){.rc = x}) #define TLDAP_RC_V(x) ((x).rc) +#else +typedef uint8_t TLDAPRC; +#define TLDAP_RC(x) (x) +#define TLDAP_RC_V(x) (x) +#endif #define TLDAP_RC_EQUAL(x,y) (TLDAP_RC_V(x)==TLDAP_RC_V(y)) #define TLDAP_RC_IS_SUCCESS(x) TLDAP_RC_EQUAL(x,TLDAP_SUCCESS) I have not yet tried it to see if it runs correctly. What function would I exercise to see if the code is working as expected?
(In reply to Tom Schulz from comment #5) > I patched tldap as follows and it now compiles. Can you send this patch in git-format-patch style to samba-technical@lists.samba.org? Thanks
Created attachment 13064 [details] Patch in git format Here is the patch in git format. I will also post this to technical.
The patch should be in master now. This is needed for both 4.5.next and 4.6.next.
Created attachment 13082 [details] git-am fix for 4.6.next, 4.5.next. Cherry-picked from master.
Hi Karolin, This is ready for 4.5 and 4.6. Thanks...
(In reply to Martin Schwenke from comment #10) Pushed to autobuild-v4-{5,6}-test.
(In reply to Karolin Seeger from comment #11) Pushed to both branches. Closing out bug report. Thanks!