Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Which 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

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Tim,

    You'd have better luck if you used the Nios II Software Build Tools (command line based). The Makefile structure is easier to follow and it gives you a reasonably complete "copy" of everything you need to build.

    You'll find examples of this flow in the software_examples sub-directory of every single hardware example that's shipped with the software ($SOPC_BUILDER_KIT/examples/[verilog|vhdl]). EDIT: in the <board>/software_examples subdirectory.

    Now, to your question/issue... I think you might be confusing GCC by specifying a bit too much. GCC has built-in paths that are searched. Type "nios2-elf-gcc -v -x c++ -E -" to get a list of which# include paths are automatically searched, among other things.

    Cheers,

    -slacker
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Slacker,

    Thanks for your reply.

    I typed your suggested nios2-elf-gcc command and received the output in the gccNiosConfig.txt file.

    Some of the output does look odd, like all the nonexistent directories. For comparison purposes I ran the same command on a different PC which still has the 7.2 version of the Altera tool set installed (gccNios72Config.txt). The output looks similar to the 9.0 installation I have, which leads me to believe that the uninstall of 7.2 and install of 9.0 didn't create the problems I am having.

    The command actually hangs after you see "End of search list." so this didn't seem normal either. Ctrl-C gets you back to Cygwin...

    I looked into some of the directories listed at the end, and I don't find stdio.h, but I do find stddef.h in "/cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/lib/gcc/nios2-elf/3.4.6/include". I'll try adding this to my RTRT build.

    I will also look into the software build tools option as you suggested.

    Cheers

    Tim
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    To complete this thread, I did end up finding the cause of this issue. It's because between 7.2 and 9.0, Altera removed the "FILE" typedef from stdio.h. I had to update my TDP to no longer reference it, and now the RTRT build works.

    Thanks

    Tim