1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Rep Power

    Declaration syntax error when compiling

    I am compiling a program for the Palm pilot using CodeWarrior v8, and writing the code in C. However: when I try to include header files with C++ "class" definitionsit gives me errors galore. I'm sure it's a simple #include statement or an #ifndef statement that I am missing, but trying those has done nothing. Here is some sample code that causes an error.

    Filename: platform.h

    #if !defined(__PLATFORM_H_INCLUDED)

    #include <PalmOS.h>
    #include <FloatMgr.h>
    //this files contains all data type declarations depending on the platform

    #define DALP_EXPORT __declspec(dllexport)
    #define DALP_IMPORT __declspec(dllimport)

    // palm os platform
    #define Dint Int32
    #define Duint unsigned Int32
    #define Dlong long
    #define Ddouble FlpDouble
    #define Dvoid void
    #define Dchar char //Single byte character
    #define Dbyte unsigned char
    #define Dfalse false
    #define Dtrue true
    #define Dbool bool
    #define Ddword unsigned long
    #define Dnull NULL
    #define NULL_LENGTH ((unsigned long) ~0)

    // some macros that support other functions

    #define lec2uint(A) (Dint) (((Dint) ((Dbyte) (A)[0])) +\
    (((Dint) ((Dbyte) (A)[1])) << 8))

    #define lec3uint(A) (Dint) (((Dint) ((Dbyte) (A)[0])) +\
    (((Dint) ((Dbyte) (A)[1])) << 8) +\
    (((Dint) ((Dbyte) (A)[2])) << 16))

    #define lec4uint(A) (Dint) (((Dint) ((Dbyte) (A)[0])) +\
    (((Dint) ((Dbyte) (A)[1])) << 8) +\
    (((Dint) ((Dbyte) (A)[2])) << 16) +\
    (((Dint) ((Dbyte) (A)[3])) << 24))

    #define int2lec(T,A) { Duint def_temp= (Duint) (A) ;\
    *((Dbyte*) (T))= (Dbyte)(def_temp); \
    *((Dbyte*) (T+1))=(Dbyte)((def_temp >> 8)); }
    #define int3lec(T,A) { \
    *((T))=(Dbyte) ((A));\
    *((T)+1)=(Dbyte) (((A) >> 8));\
    *((T)+2)=(Dbyte) (((A) >> 16)); \
    #define int4lec(T,A) { *(T)=(Dbyte) ((A));\
    *((T)+1)=(Dbyte) (((A) >> 8));\
    *((T)+2)=(Dbyte) (((A) >> 16));\
    *((T)+3)=(Dbyte) (((A) >> 24)); }

    //global functions
    void fnGetExternalErrorMessageText(Dchar* pErrorMessage, Dchar* pszFunctionName);

    class DalpMemStrRoutines{
    static Dchar* StringCopy( Dchar* pszDestination, const Dchar* pszSource);
    static Dint StringLength(const Dchar *pszString);
    static Dvoid* MemoryCopy(Dvoid* pDest, const Dvoid* pSrc, Dint nCount);
    static Dvoid* MemorySet(Dvoid* pDest, Dint nChar, Dint nCount);};

    #define DALP_D_ITOD(X) (_d_itod(X))
    #define DALP_D_DTOI(X) (_d_dtoi(X))
    #define DALP_D_DIV(X,Y) (_d_div(X,Y))
    #define DALP_D_MUL(X,Y) (_d_mul(X,Y))

    #define ASSERT(X) \
    do {if (Dnull == X) ErrDisplayFileLineMsg(__FILE__, (UInt16) __LINE__, "Null Pointer passed as parameter");} while (0)

    #define SOCKET_ERROR (-1)


    The error that it gives upon compiling, when I #include platform.h in my source file is:
    "Error: declaration syntax error
    platform.h line 91 class DalpMemStrRoutines "

    This is only the first of many errors, all of which seem to be a part of C++ (eg: it'll also complain about the next line after this error where "public:" is used)

    Am I doing something obviously wrong?

    Thank you for your help,
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Rep Power


    Turns out that it was the stupidest error ever! All the errors were because my files were with the ".c" extension and not ".cpp" (or whatever C++ extension tickles your fancy). As soon as I changed the files names: Voila! and it worked.

IMN logo majestic logo threadwatch logo seochat tools logo