Shop OBEX P1 Docs P2 Docs Learn Events
Is Anyone Familiar With stdarg.h? I Want To Have A Discussion About This File. — Parallax Forums

Is Anyone Familiar With stdarg.h? I Want To Have A Discussion About This File.

idbruceidbruce Posts: 6,197
edited 2015-03-11 10:16 in Propeller 1
I have a C program that I am working on and during compilation, a huge list of warnings are issued. I have not got to the point of weeded them out, but I know that most of them are caused by the use of stdarg.h and the use of various data types. I am looking at having a serious discussion about resolving these warnings, because they annoy me. :)

The code works fines and I could probably uncheck the "All Warnings" option in SimpleIDE, at which point all warnings disappear, but I do not want to lose track of any warnings that are not associated with the use of stdarg.h.

Comments

  • Dave HeinDave Hein Posts: 6,347
    edited 2015-03-10 19:28
    Are the warnings related to using int16_t with va_arg()? It appears that you can only use 32-bit types with va_arg.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-10 20:15
    Dave
    Are the warnings related to using int16_t with va_arg()? It appears that you can only use 32-bit types with va_arg.

    Actually Dave, in my instance it is the use of uint8_t and uint16_t data types, however I am sure that the use of int8_t or int16_t would generate warnings as well. To my understanding, you are partially correct. If the data type is not uint32_t or int32_t, providing it is not type char, then it is promoted to a double (that is what I have read). As I am sure you are aware, this problem relates to the sersendf_P function, within sersendf.c, within Teacup. The sersendf_P function then takes the data and passes it along to various functions within sermsg.c for further processing. Additonally as you know, I could not get it to compile, without altering some of the functions and doing various type casts. As mentioned, it now compiles and works fine, but those numerous warnings may be hiding other warnings that I really need to see.

    I could try to duplicate the functionality of stdarg.h, but with different data types, but that may be opening up a can of worms.

    In sersendf.c, they say this about the sersendf_P function:
    /** \brief Simplified printf
    	\param format pointer to output format specifier string stored in FLASH.
    	\param ... output data
    

    This doesn't sound accurate at all, unless it is writing the string to flash, instead of outputting to a terminal. As it stands now (with the files I am keeping), the sersendf_P function is called 43 times by the following various files:

    dda.c
    dda_lookahead.c
    dda_queue.c
    gcode_parse.c
    gcode_process.c

    during the use of these files, an object is being printed, so I cannot see why this information would be written to flash, instead of being display. If is simply display text, then the problem would easily be resolved, by eliminating sersendf.c, sersendf,h, sermsg.c, and sermsg.h, and using print or printf instead.

    EDIT: I will add that I have not found proof one way or another, where these strings are going, but I may have overlooked it.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-10 20:40
    In case it helps to resolve this issue.... Here is the declaration of sersendf_P.....

    void sersendf_P(PGM_P format, ...) __attribute__ ((format (printf, 1, 2)));

    PGM_P is defined as follows.....

    #define PGM_P const char *


    As metioned in the previous post,.....
    The sersendf_P function then takes the data and passes it along to various functions within sermsg.c for further processing.

    At the beginning of sermsg.c it says this....
    /** \file sermsg.c
    	\brief primitives for sending numbers over the serial link
    */
    
  • Heater.Heater. Posts: 21,230
    edited 2015-03-11 03:26
    Bruce,
    I could try to duplicate the functionality of stdarg.h
    Your really don't want to be messing with stdarg.h. That "std" is there for a reason, it's parts part of the language standard.

    I presume we are still talking about Teacup here. That code builds and runs on systems with 16 bit ints (AVR) and 32 bit ints (PC simulator) so presumably it can be a big deal to get it to compile for the 32 bit Propeller.

    Far better to try and cast any 8 or 16 bit parameters to 32 bit when making the calls if possible.

    I can't really say as I as you don't say exactly what sources we are talking about or what warnings are coming out.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 04:13
    Heater
    Your really don't want to be messing with stdarg.h. That "std" is there for a reason, it's parts part of the language standard.

    I wasn't really talking about altering stdarg.h, but more like creating my own "stdarg.h" + "stdarg.c", renaming them to like "mystdarg.h" + "mystdarg.c" and then use the functions of mystdarg.h..

    Yes I am talking about Teacup. However, to be more specific, sersendf_P is a variadic function, which receives an indefinite number of arguments with unkonown data types, similar to printf.

    I have to run an errand, but in the meantime, here is a list of warnings.
    Project Directory: C:/Documents and Settings/Bruce/My Documents/SimpleIDE/My Projects/Forger/
    
    SimpleIDE Version 1.0.2
    C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/
    C:/Documents and Settings/Bruce/My Documents/SimpleIDE/ Updated on: 2015-02-14
    
    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c dda.c -o cmm/dda.o
    dda.c: In function 'dda_create':
    dda.c:131:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:131:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:131:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:131:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'int32_t' [-Wformat]
    dda.c:131:4: warning: too many arguments for format [-Wformat-extra-args]
    dda.c:201:4: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int32_t' [-Wformat]
    dda.c:201:4: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int32_t' [-Wformat]
    dda.c:201:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int32_t' [-Wformat]
    dda.c:201:4: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'int32_t' [-Wformat]
    dda.c:231:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda.c:270:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda.c: In function 'dda_start':
    dda.c:422:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:422:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:422:4: warning: unknown conversion type character 'q' in format [-Wformat]
    dda.c:422:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'int32_t' [-Wformat]
    dda.c:422:4: warning: too many arguments for format [-Wformat-extra-args]
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c dda_lookahead.c -o cmm/dda_lookahead.o
    dda_lookahead.c: In function 'dda_find_crossing_speed':
    dda_lookahead.c:230:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:230:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 6 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 7 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 8 has type 'int32_t' [-Wformat]
    dda_lookahead.c:248:4: warning: format '%ld' expects argument of type 'long int', but argument 9 has type 'int32_t' [-Wformat]
    dda_lookahead.c:288:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:288:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:288:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:288:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:306:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:306:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:306:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:306:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:324:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:324:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:324:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:324:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:342:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:342:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:342:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:342:5: warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'unsigned int' [-Wformat]
    dda_lookahead.c:358:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    dda_lookahead.c:358:4: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat]
    dda_lookahead.c: In function 'dda_join_moves':
    dda_lookahead.c:434:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint32_t' [-Wformat]
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c dda_maths.c -o cmm/dda_maths.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c dda_queue.c -o cmm/dda_queue.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c debug.c -o cmm/debug.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c gcode_parse.c -o cmm/gcode_parse.o
    gcode_parse.c: In function 'gcode_parse_char':
    gcode_parse.c:561:6: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'uint32_t' [-Wformat]
    gcode_parse.c:569:5: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'uint32_t' [-Wformat]
    gcode_parse.c:569:5: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'uint32_t' [-Wformat]
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c gcode_process.c -o cmm/gcode_process.o
    gcode_process.c: In function 'process_gcode_command':
    gcode_process.c:780:6: warning: unknown conversion type character 'q' in format [-Wformat]
    gcode_process.c:780:6: warning: unknown conversion type character 'q' in format [-Wformat]
    gcode_process.c:780:6: warning: unknown conversion type character 'q' in format [-Wformat]
    gcode_process.c:780:6: warning: unknown conversion type character 'q' in format [-Wformat]
    gcode_process.c:780:6: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'int32_t' [-Wformat]
    gcode_process.c:780:6: warning: too many arguments for format [-Wformat-extra-args]
    gcode_process.c:460:11: warning: unused variable 'i' [-Wunused-variable]
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c home.c -o cmm/home.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c pinio.c -o cmm/pinio.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c sermsg.c -o cmm/sermsg.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c sersendf.c -o cmm/sersendf.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c sergcode.c -o cmm/sergcode.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 -c Adafruit_ADS1015.c -o cmm/Adafruit_ADS1015.o
    propeller-elf-gcc.exe -I . -L . -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Documents and Settings/Bruce/My Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -o cmm/Forger.elf -Os -mcmm -Wall -m32bit-doubles -fno-exceptions -std=c99 cmm/dda.o cmm/dda_lookahead.o cmm/dda_maths.o cmm/dda_queue.o cmm/debug.o cmm/gcode_parse.o cmm/gcode_process.o cmm/home.o cmm/pinio.o cmm/sermsg.o cmm/sersendf.o cmm/sergcode.o cmm/Adafruit_ADS1015.o -ffunction-sections -fdata-sections -Wl,--gc-sections Forger.c -lsimpletools -lsimpletext -lsimplei2c -lfdserial -lsimpletools -lsimpletext -lsimplei2c -lsimpletools -lsimpletext -lsimpletools
    Forger.c: In function 'main':
    Forger.c:278:12: warning: unused variable 'extruder_fahrenheit' [-Wunused-variable]
    propeller-load -s cmm/Forger.elf
    propeller-elf-objdump -h cmm/Forger.elf
    Done. Build Succeeded!
    
    
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 06:39
    Although sersendf.c needed to be altered to enable compilation, I now think that I may have removed an existing "stdarg.h" "workaround" that should have remained.

    I will test this theory and let you know the results.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-11 06:45
    Is the project on github or something? I'd love to help and might have some suggestions, but it'd be a lot easier if I could pull the source code and take a look
  • Heater.Heater. Posts: 21,230
    edited 2015-03-11 07:00
    It's on github here: https://github.com/Traumflug/Teacup_Firmware

    Interestingly when I compile dda.c for the simulator using their make file with GCC on my PC it compiles with the options "-Wall -Wstrict-prototypes -Wno-format -Wno-format-security"

    That is to say warm me about everything except those pesky format issues. This suggests that these warnings are known about and have been deliberately suppressed in their Make file and presumably know are not dangerous. Not a practice I condone but there we go.

    I would not want to provide a mystdarg.h if I were doing this, at the end of the day whatever mods are made for getting this to work on a Propeller the thing should still be buildable in simulator mode.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 07:11
    if I were doing this, at the end of the day whatever mods are made for getting this to work on a Propeller the thing should still be buildable in simulator mode.

    I am curious why you say that? What are the real benefits to the simulator, besides debugging?

    I really do not enough about the simulator to make any kind of judgement about it's usefulness, but I do know for a fact, that adding the simulator will compound the complexity of the project, especially at this point. As I told Dave, when I get it running, then I could go through it one more time to add the simulator back in.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-11 07:16
    Heater. wrote: »

    Looks like the original source correct? Has Bruce posted his modifications anywhere?
  • Dave HeinDave Hein Posts: 6,347
    edited 2015-03-11 07:35
    va_arg is defined in stdarg.h as "#define va_arg(v,l) __builtin_va_arg(v,l)". I don't know how __builtin_va_arg is implemented, but it seems to be incorporated into the compiler. va_arg is used to get the next value off of a function parameter list. The type needs to be known so that it knows how many bytes to pull off the list. However, I believe the parameter list is stored as 32-bit values and types such as int8_t and int16_t are promoted to 32 bits when creating the parameter list. So I think the type is important only when a larger type is used, such as a 64-bit double.

    If I were you, I would change every use of va_arg in the Teacup code to something like "(uint16_t)va_arg(v,int)". This will eliminate the warnings, and the code will work as expected.

    EDIT: I agree with Heater about the simulator mode. It would be cleaner to start with the simulator mode and then add Prop-specific drivers. Your current approach requires working around a lot of AVR stuff. The simulator mode eliminates most of that. Don't be confused by the term "simulator". From what I understand, the simulator mode is fully functional except that it simulates I/O using a serial port or files. I think you could actually drive a 3D printer from the serial output if the 3D printer accepted serial input.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 07:42
    SwimDude0614
    Is the project on github or something? I'd love to help and might have some suggestions, but it'd be a lot easier if I could pull the source code and take a look

    If you really want to jump in.... :) Download the master files. Then depending upon what you really want to do, I would suggest downloading the archive below, because it will save you a lot of time, or you can start fresh.

    Then here is a link to the Teacup port thread: http://forums.parallax.com/showthread.php/159950-The-Teacup-Port-A-Work-In-Progress-3D-Printer-Firmware, but go to the end, because for a while, I was going in useless circles.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 07:50
    Dave
    EDIT: I agree with Heater about the simulator mode. It would be cleaner to start with the simulator mode and then add Prop-specific drivers. Your current approach requires working around a lot of AVR stuff. The simulator mode eliminates most of that. Don't be confused by the term "simulator". From what I understand, the simulator mode is fully functional except that it simulates I/O using a serial port or files. I think you could actually drive a 3D printer from the serial output if the 3D printer accepted serial input.

    Oh no, I am not starting over again :) I have come to far to turn back now. The archive above now includes Adafruit_ADS1015.cpp and Adafruit_ADS1015.cpp, which when finished, should remove most of the remaining AVR code. There will still be a little bit lingering here and there, but I am getting there slowly but surely.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-03-11 08:25
    Thanks for the zip. Wrote up a quick CMakeLists.txt file and built first time with Propware :)

    Anyway, looking at sersendf.c, that's a highly modified version of printf. Because of the special characters (the 'q' for instance), I wouldn't have marked it as a printf function in the first place. In the header file, you can see the prototype is written as:
    void sersendf_P(PGM_P format, ...)	__attribute__ ((format (printf, 1, 2)));
    

    I'd take off that format attribute. I'd also go through all the instances using %ld and %lu and switch them to %u and %d. Presumably, int is 16 bits on the arduino and long int is 32-bits, which is why they used ld and lu. But... the Propeller is infinitely cooler because we get 32-bit ints :)

    I can't help myself. Here's the long and complicated CMake file. All 33 lines of it.
    ################################################################################
    ### Template code. Do not modify                                               #
                                                                                   #
    cmake_minimum_required (VERSION 3.0.0)                                         #
    # Aside from cmake_minimum_required, this must be the first two lines          #
    # of the file                                                                  #
    file(TO_CMAKE_PATH $ENV{PROPWARE_PATH} PROPWARE_PATH)                          #
    include(${PROPWARE_PATH}/CMakePropellerHeader.cmake)                           #
    ################################################################################
    
    set(BOARD GENERIC)
    set(MODEL cmm)
    set(COMMON_FLAGS "-Os")
    
    project(Forger C)
    
    create_simple_executable(${PROJECT_NAME}
        ${PROJECT_NAME}
        Adafruit_ADS1015
        config
        dda
        dda_lookahead
        dda_maths
        dda_queue
        debug
        gcode_parse
        gcode_process
        home
        pinio
        propellerized
        sergcode
        sermsg
        sersendf)
    
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 09:45
    Alright....

    I should have been following my original intent all along, but I wanted to take baby steps. I have figured out how to resolve the warnings and I don't know if it is the right thing to do, but I am going to run with it.

    sersendf.c, sersendf.h, sermsg.c, and sermsg.h, will soon be a thing of the past, and these files will all be deleted. functions of these files will be replaced with "print".
  • ersmithersmith Posts: 6,053
    edited 2015-03-11 10:13
    I think David nailed the problem in message 15 -- it's the __attribute__() on sersendf_P which is mistakenly telling the compiler that it has the same kind of format string as printf (it doesn't, the %q format is different, for example). Just removing that attribute from sersendf_P (and any related functions) should make all of your warnings go away.

    Replacing stdarg would not help this situation, since the warnings are about the printf formats, not about anything that stdarg.h does. Besides which, Heater is very much correct that replacing standard header files is usually a bad idea. It's not possible to change stdarg.h behavior in this case -- the compiler itself is promoting int8_t and int16_t to int, and is doing so in accordance with the language definition. But that's a red herring anyway, because the warnings in your message are not because of variable promotion, but because the compiler is checking the string as if it were a printf format, and it isn't.
  • idbruceidbruce Posts: 6,197
    edited 2015-03-11 10:16
    I figured out how to resolve these warnings, but thanks for your input anyhow.
Sign In or Register to comment.