Shop OBEX P1 Docs P2 Docs Learn Events
Compilation warnings coming from attempting to convert a spin object in to Propeller C — Parallax Forums

Compilation warnings coming from attempting to convert a spin object in to Propeller C

I wrote a simple error-info object in spin, and since I want to use XMM at some point, I'm converting all the spin code i wrote into Propeller C starting with this one.


My first attempt to convert the spin to C kind went okay-ish since there's some unwanted minor changes but no compilation warnings or errors.
The unwanted changes are that in the original spin, only the error-string (len(errstr)) would be copied over not the whole buffer (len(buffer[32])


My second attempt to put right the problems from the first attempt has compiled successfully but with lot of warnings...


I'd like to fix the warnings so it compiles without warnings.
I'm finding it hard to address the compiler warnings since its very hard to understand the cause's of each of the warnings.
Can anyone help me de-cipher the warnings please?
Thanks


The files attached are:
ErrorInfo-Spin.txt - The spin object
ErrorInfo1-C.txt - The first attempt at converting spin to C
ErrorInfo2-C.txt - The second attempt at converting spin to C




Compiler Warnings
All the warnings below are related to ErrorInfo-C2.txt (The second attempt at converting spin to C)
Project Directory: C:/Users/docza/Documents/SimpleIDE/My Projects/Testing/testbed3/

SimpleIDE Version 1.1.2
C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/
C:/Users/docza/Documents/SimpleIDE/ Updated on: 2020-11-23

propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
propeller-elf-gcc.exe -I . -L . -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 -c New File.c -o cmm/New File.o
New File.c: In function 'Ei1MoveGenericString':
New File.c:105:7: warning: passing argument 1 of 'strlen' from incompatible pointer type [enabled by default]
c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include/string.h:39:8: note: expected 'const char *' but argument is of type 'unsigned int *'
New File.c:105:14: warning: assignment makes pointer from integer without a cast [enabled by default]
New File.c:108:18: warning: comparison between pointer and integer [enabled by default]
New File.c:110:17: warning: assignment makes pointer from integer without a cast [enabled by default]
New File.c:112:7: warning: passing argument 3 of 'memcpy' makes integer from pointer without a cast [enabled by default]
c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include/string.h:11:8: note: expected 'size_t' but argument is of type 'const char *'
New File.c: In function 'Ei1GetErrTitle':
New File.c:162:7: warning: passing argument 1 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[33]'
New File.c: In function 'Ei1SetErrTitle':
New File.c:170:7: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[33]'
New File.c: In function 'Ei1GetErrDesc':
New File.c:178:7: warning: passing argument 1 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[65]'
New File.c: In function 'Ei1SetErrDesc':
New File.c:186:7: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[65]'
New File.c: In function 'Ei1SetErrorInfo':
New File.c:214:13: warning: passing argument 1 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[17]'
New File.c:214:13: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[33]'
New File.c:218:13: warning: passing argument 1 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[61]'
New File.c:218:13: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[65]'
New File.c:225:13: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[33]'
New File.c:229:13: warning: passing argument 2 of 'Ei1MoveGenericString' from incompatible pointer type [enabled by default]
New File.c:100:9: note: expected 'unsigned int *' but argument is of type 'char (*)[65]'
propeller-elf-gcc.exe -I . -L . -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/docza/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -o cmm/textbed3.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 cmm/New File.o textbed3.c -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm
propeller-load -s cmm/textbed3.elf
propeller-elf-objdump -h cmm/textbed3.elf

Comments

  • RaymanRayman Posts: 14,639
    I think what you are seeing is the result of C being sensitive to the type of pointer declared, where Spin is not even aware if something is a pointer or not...

    Looks to me like "unsigned int *plSrcStrAddr" should be "char *plSrcStrAddr", and the same for "plDestStrAddr".

    If you still have trouble, you can typecast to get rid of the warnings.

       //-> Ei1MoveGenericString
       void Ei1MoveGenericString(unsigned int *plSrcStrAddr, unsigned int *plDestStrAddr, char pbMaxLen)
       {
          const char *tmpLen;
          
          // Get length of src-string
          tmpLen = strlen(plSrcStrAddr);
          
          // Limit length if over maxlen
          if (tmpLen > pbMaxLen)
          {
             tmpLen = pbMaxLen;
          }
          memcpy(plDestStrAddr, plSrcStrAddr, tmpLen);      
       }
    
  • You also need to remove the "&" when passing the address of the _baErr... arrays. When you reference a char array by its name it has the type (char *), which is a pointer that points to the first element in the array.
  • Thank You Rayman and Dave Hein,

    Taking the advice that both of you offered has resolved all the compiler warnings I was getting before.

    I feel that if there were a cross reference of the Spin keywords to their equivalent C keywords,
    it would make it a simple job for a basic/spin programmer to learn C and vice versa...

    I found it exceedingly laborious to drill through the SimpleIde pdf to find the right keyword and in most cases it was a complete waste of time,
    because looking for something when your not sure what your'e looking for is tedious and time consuming.

    And finally posting my problems here helped immensely, where in one night I managed to resolve errors and warnings which were causing me problems for days and days.


    I've not posted the common.h file since it only contains the single prototype declaration for the one method in the common.c file
Sign In or Register to comment.