IBM XL C/C++ error with client/smbspool.c

yaberger at ca.ibm.com yaberger at ca.ibm.com
Tue Aug 5 19:40:55 GMT 2008


Hello,

I had a discussion monday with Volker about another strange error I'm 
getting on AIX but this one is probably only related to my compiler (IBM 
XL C/C++ 10.1 and 8)

so this is the error:
Using FLAGS      =  -O -D_SAMBA_BUILD_=3 -D_LINUX_SOURCE_COMPAT 
-qmaxmem=32000 -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 
-I/usr/src/samba-3.2.0/source/popt 
-I/usr/src/samba-3.2.0/source/iniparser/src -Iinclude -I./include  -I. -I. 
-I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc 
-DHAVE_CONFIG_H  -Iinclude -I./include -I. -I. -I./lib/replace 
-I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt 
-I/include -I/usr/src/samba-3.2.0/source/lib -D_SAMBA_BUILD_=3
      PICFLAG    = -O2
      LIBS       =
      LDFLAGS    = -L./bin
      DYNEXP     = -Wl,-brtl,-bexpfull,-bbigtoc
      LDSHFLAGS  = -Wl,-G,-bexpfull,-bbigtoc,-brtl  -L./bin
      SHLIBEXT   = so
      SONAMEFLAG = #
Compiling client/smbspool.c
"client/smbspool.c", line 332.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 332.42: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 333.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 333.46: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 334.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 334.49: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 335.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 335.43: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 336.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 336.48: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 337.17: 1506-221 (S) Initializer must be a valid 
constant expression.
"client/smbspool.c", line 337.45: 1506-221 (S) Initializer must be a valid 
constant expression.
The following command failed:
cc -qlanglvl=extc89 -qlanglvl=extc99 -I. -I/usr/src/samba-3.2.0/source  -O 
-D_SAMBA_BUILD_=3 -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 
-D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -I/usr/src/samba-3.2.0/source/popt 
-I/usr/src/samba-3.2.0/source/iniparser/src -Iinclude -I./include  -I. -I. 
-I./lib/replace -I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc 
-DHAVE_CONFIG_H  -Iinclude -I./include -I. -I. -I./lib/replace 
-I./lib/talloc -I./lib/tdb/include -I./libaddns -I./librpc -I./popt 
-I/include -I/usr/src/samba-3.2.0/source/lib -D_SAMBA_BUILD_=3 -O2 -c 
client/smbspool.c -o client/smbspool.o
make: 1254-004 The error code from the last command is 1.


Stop.


which is the related to the initialization of the following array
        static const NTSTATUS auth_errors[] =
        {
                NT_STATUS_ACCESS_DENIED, NT_STATUS_ACCESS_VIOLATION,
                NT_STATUS_SHARING_VIOLATION, NT_STATUS_PRIVILEGE_NOT_HELD,
                NT_STATUS_INVALID_ACCOUNT_NAME, NT_STATUS_NO_SUCH_USER,
                NT_STATUS_WRONG_PASSWORD, NT_STATUS_LOGON_FAILURE,
                NT_STATUS_ACCOUNT_RESTRICTION, 
NT_STATUS_INVALID_LOGON_HOURS,
                NT_STATUS_PASSWORD_EXPIRED, NT_STATUS_ACCOUNT_DISABLED
        };

removing the static resolve the problem, but I don't think this would be 
the good way to fix it


I've HAVE_IMMEDIATE_STRUCTURES set to 1 so in include/nt_status.h.
The following typedef and define are used:
typedef struct {uint32 v;} NTSTATUS;
#define NT_STATUS(x) ((NTSTATUS) { x })

If I force the undef of HAVE_IMMEDIATE_STRUCTURES in include/nt_status.h, 
I'm able to finish the compilation of this file and everything else

Having HAVE_IMMEDIATE_STRUCTURES set to undef use the following typedef 
and define instead:
typedef uint32 NTSTATUS;
#define NT_STATUS(x) (x)

so I've tried to reproduce the same problem in a smaller program

First code is the problematic one.
#include "sys/ltypes.h"

typedef struct {uint32 v;} NTSTATUS;
#define NT_STATUS(x) ((NTSTATUS) { x })
#define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022)

int main()
{
        static const NTSTATUS auth_errors[] =
        {
                NT_STATUS_ACCESS_DENIED
        };

        return 0;
}

 ==> cc test.c
"test.c", line 11.17: 1506-221 (S) Initializer must be a valid constant 
expression.


Second code is working great with my compiler, just like if the value of 
HAVE_IMMEDIATE_STRUCTURES is undef
#include "sys/ltypes.h"

typedef uint32 NTSTATUS;
#define NT_STATUS(x) (x)
#define NT_STATUS_ACCESS_DENIED NT_STATUS(0xC0000000 | 0x0022)

int main()
{
        static const NTSTATUS auth_errors[] =
        {
                NT_STATUS_ACCESS_DENIED
        };

        return 0;
}




I think we should test the first little program in the configure step (ie 
in the file lib/replace/libreplace_cc.m4).
If it's able to compile, #define HAVE_IMMEDIATE_STRUCTURES 1, else 0, 
undef, no action, whatever we should do if we don't fully support 
immediate structures

What's your opinion on this proposition before I start working on a patch 
for lib/replace/libreplace_cc.m4



Regards,

Yannick Bergeron
yaberger at ca.ibm.com


More information about the samba-technical mailing list