Altera_Forum
Honored Contributor
15 years agoWhich stdio.h / stddef.h
Hi, Sorry this is a newbie-type (and long) question. The good: I am working in Nios II EDS 9.0 under Windows and Eclipse. I am able to do a printf in the main function of my build and see it appear the Eclipse console. Using the Cygwin command shell, I can then navigate to the makefile, and compile from the command line. For a typical .c file compilation, I see: nios2-elf-gcc -xc -MD -c -DSYSTEM_BUS_WIDTH=32 -DALT_NO_CLEAN_EXIT -DALT_NO_C_PLUS_PLUS -DALT_NO_INSTRUCTION_EMULATION -DALT_USE_SMALL_DRIVERS -I.. -I/cygdrive/c/quartuswork/compact_sensor/CPE_Op/software/CPE_OFF_Chip_syslib/Debug/system_description -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_epcs_flash_controller/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_epcs_flash_controller/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_jtag_uart/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_jtag_uart/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_spi/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_spi/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_uart/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_uart/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_timer/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_timer/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_sysid/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_sysid/inc -I/cygdrive/c/altera/90/ip/altera/nios2_ip/altera_nios2/HAL/inc -I/cygdrive/c/altera/90/nios2eds/components/altera_hal/HAL/inc -DALT_SINGLE_THREADED -D__hal__ -pipe -DALT_DEBUG -O1 -g -Wall -mno-hw-mul -mno-hw-div -o obj/compact_sensor_main.o ../compact_sensor_main.c I also see the link command, etc. all good, so the makefile based build works for me. The bad news is I am trying to instrument my build using the IBM RTRT tool. I am trying to do so by replicating the includes and defines shown above, plus add some RTRT-specific paths. However when I do so I typically see the following: ************* Entering Compilation Function...*************** Defines: -DALT_DEBUG -DSYSTEM_BUS_WIDTH=32 -DALT_NO_CLEAN_EXIT -DALT_NO_C_PLUS_PLUS -DALT_NO_INSTRUCTION_EMULATION -DALT_USE_SMALL_DRIVERS -DALT_SINGLE_THREADED -D__hal__ Includes: -I. -I.. -I/cygdrive/c/quartuswork/compact_sensor/CPE_Op/software/CPE_OFF_Chip_syslib/Debug/system_description -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_epcs_flash_controller/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_epcs_flash_controller/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_jtag_uart/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_jtag_uart/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_spi/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_spi/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_uart/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_uart/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_timer/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_timer/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_sysid/HAL/inc -I/cygdrive/c/altera/90/ip/altera/sopc_builder_ip/altera_avalon_sysid/inc -I/cygdrive/c/altera/90/ip/altera/nios2_ip/altera_nios2/HAL/inc -I/cygdrive/c/altera/90/nios2eds/components/altera_hal/HAL/inc -I/cygdrive/c/altera/90/quartus/bin/cygwin/usr/include/w32api -I/cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/nios2-elf/include/sys -I/cygdrive/c/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib -I/cygdrive/c/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib CFlags: -O1 -g -Wall -pipe -mno-hw-mul -mno-hw-div Out: ./TP.o Source: C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/TP.c In file included from C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/TP.c:30: C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:213: error: syntax error before '*' token C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:214: warning: return type defaults to `int' C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:225: error: syntax error before '*' token C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:227: warning: return type defaults to `int' C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h: In function `usr_open': C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:232: error: `FILE' undeclared (first use in this functio n) C:/soft/Rational/TestRealTime/targets/CMC_NIOS_CPE_Op_Host/lib/custom.h:232: error: (Each undeclared identifier is reported only ... As you can see the compile doesn't understand what "FILE" is, which is normally defined in stdio.h in ISO C. Things go south quickly after that. The stdio.h file I am pulling only has very limited content, i.e. /cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/nios2-elf/inc lude/sys [NiosII EDS]$ cat stdio.h # ifndef _NEWLIB_STDIO_H # define _NEWLIB_STDIO_H /* Internal locking macros, used to protect stdio functions. In the general case, expand to nothing. */ # if !defined(_flockfile) # define _flockfile(fp) # endif # if !defined(_funlockfile) # define _funlockfile(fp) # endif # endif /* _NEWLIB_STDIO_H */ /cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/nios2-elf/inc lude/sys [NiosII EDS]$ which doesn't include a definition for "FILE" for example. I search and there are 21 other stdio.h files under c:\altera\90, many of which have more content, but then I get an error about missing the stddef.h file. So... I guess my question is, which stdio.h should I be including in this case? Other advice would be appreciated, since this is a road-block for me currently. Thanks for your interest, Tim