1

I am trying to generate gsoap classes from a header file

soapcpp2.exe test.h

where test.h

// test.h

#define MY_STRUCT_NAME_LEN 50

typedef struct MY_STRUCT_TYPE
{
    char name[MY_STRUCT_NAME_LEN];
}MY_STRUCT;

int op1(MY_STRUCT* a, int b, int * r );

my problem is that #define MY_STRUCT_NAME_LEN 50 al line:3 is not recognised.

test.h(7): *WARNING*: undefined identifier 'MY_STRUCT_NAME_LEN'


test.h(7): *WARNING*: char[30681240620171331] will be serialized as an array of 30681240620171331 bytes: use soapcpp2 option -b to enable char[] string serialization or use char* for strings


    test.h(7): **ERROR**: undetermined array size

    Saving soapStub.h annotated copy of the source interface header file
    Saving soapH.h serialization functions to #include in projects

    test.h(12): *WARNING*: serializable typedef 'MY_STRUCT' is not namespace qualified: schema definition for 'MY_STRUCT' in WSDL file output may be invalid

    Saving soap.nsmap namespace mapping table
    Saving soapClient.cpp client call stub functions
    Saving soapClientLib.cpp client stubs with serializers (use only for libs)
    Saving soapServer.cpp server request dispatcher
    Saving soapServerLib.cpp server request dispatcher with serializers (use only for libs)
    Saving soapC.cpp serialization functions

    There were errors:
    1 semantic error
    3 warnings

If I change line:7 to

char name[50];

it will work fine.

I would really prefer to use macros for size of string (the real case is more complex). Can someone help on this ?

cprogrammer
  • 5,503
  • 3
  • 36
  • 56

1 Answers1

0

As this question is marked C++ and you are using soapcpp2: You probably shouldn't use defines, typedef struct ... and char-arrays for strings. This said and if there is no particular reason to limit the string length, rewriting your code to:

class test {
    public:
    std::string name;
};

int op1(test* a, int b, int * r );

Results in successfull compilation without any warnings.

user1810087
  • 5,146
  • 1
  • 41
  • 76