Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

Predefined Macro Issues (__VERSION__ and __NIOS2__)

Altera_Forum
Honored Contributor II
1,547 Views

I rebuilt a NIOS2 SBT project (12.1sp1) and started getting some errors I didn't have previously. 

 

The first error was "symbol __version__ could not be resolved". 

 

The other error was for a conditional compilation using the __NIOS2__ predefined symbol, which when I build doesn't seem to be defined. 

 

I ran the following to see the macros defined.nios2-elf-gcc -dm -e -x c testmacros.txt 

 

 

It appears __VERSION__ and __NIOS2__ are both specified. 

# define __DBL_MIN_EXP__ (-1021)# define __FLT_MIN__ 1.17549435e-38F# define __CHAR_BIT__ 8# define nios2_little_endian 1# define __WCHAR_MAX__ 2147483647# define __DBL_DENORM_MIN__ 4.9406564584124654e-324# define __FLT_EVAL_METHOD__ 0# define __nios2_little_endian__ 1# define __DBL_MIN_10_EXP__ (-307)# define __FINITE_MATH_ONLY__ 0# define __GNUC_PATCHLEVEL__ 2# define __SHRT_MAX__ 32767# define __LDBL_MAX__ 1.7976931348623157e+308L# define __UINTMAX_TYPE__ long long unsigned int# define __LDBL_MAX_EXP__ 1024# define __SCHAR_MAX__ 127# define __nios2__ 1# define __STDC_HOSTED__ 1# define __LDBL_HAS_INFINITY__ 1# define NIOS2 1# define __DBL_DIG__ 15# define __FLT_EPSILON__ 1.19209290e-7F# define __LDBL_MIN__ 2.2250738585072014e-308L# define __nios2 1# define __DECIMAL_DIG__ 17# define __NIOS2 1# define __LDBL_HAS_QUIET_NAN__ 1# define __GNUC__ 4# define __FLT_HAS_DENORM__ 1 

#define __nios2__ 1# define __DBL_MAX__ 1.7976931348623157e+308# define __DBL_HAS_INFINITY__ 1# define __LDBL_HAS_DENORM__ 1# define __USING_SJLJ_EXCEPTIONS__ 1# define __DBL_MAX_EXP__ 1024# define __LONG_LONG_MAX__ 9223372036854775807LL# define __GXX_ABI_VERSION 1002# define __FLT_MIN_EXP__ (-125)# define __DBL_MIN__ 2.2250738585072014e-308# define __DBL_HAS_QUIET_NAN__ 1# define __REGISTER_PREFIX__ # define __DBL_HAS_DENORM__ 1# define __NO_INLINE__ 1# define __FLT_MANT_DIG__ 24 

#define __version__ "4.1.2"# define __SIZE_TYPE__ long unsigned int# define __ELF__ 1# define __nios2_5b__ 1# define __FLT_RADIX__ 2# define __LDBL_EPSILON__ 2.2204460492503131e-16L# define nios2_5b 1# define __USER_LABEL_PREFIX__ # define __LDBL_DIG__ 15# define __FLT_HAS_QUIET_NAN__ 1# define __FLT_MAX_10_EXP__ 38# define __LONG_MAX__ 2147483647L# define __FLT_HAS_INFINITY__ 1# define __nios2_5b 1# define __nios2_little_endian 1# define __LDBL_MANT_DIG__ 53# define __WCHAR_TYPE__ int# define __FLT_DIG__ 6# define __INT_MAX__ 2147483647# define __FLT_MAX_EXP__ 128# define __DBL_MANT_DIG__ 53# define __WINT_TYPE__ unsigned int# define __LDBL_MIN_EXP__ (-1021)# define __LDBL_MAX_10_EXP__ 308# define __DBL_EPSILON__ 2.2204460492503131e-16# define nios2 1# define __INTMAX_MAX__ 9223372036854775807LL# define __FLT_DENORM_MIN__ 1.40129846e-45F# define __FLT_MAX__ 3.40282347e+38F# define __FLT_MIN_10_EXP__ (-37)# define __INTMAX_TYPE__ long long int# define __GNUC_MINOR__ 1# define __DBL_MAX_10_EXP__ 308# define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L# define __STDC__ 1# define __PTRDIFF_TYPE__ long int# define __LDBL_MIN_10_EXP__ (-307) 

 

 

Reference: 

http://nadeausoftware.com/articles/2011/12/c_c_tip_how_list_compiler_predefined_macros
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
564 Views

SBT 12.1sp1 

 

I got around the __NIOS2__ issue by recreating the whole project. 

 

__VERSION__ not resolved issue fix as follows:  

 

Right Click Project Folder -> Properties-> C/C++ General-> Code Analysis->Use project settings (or configure workspace settings)-> Potential Programming Problems-> Syntax and Semantic Errors-> Uncheck Symbol is not resolved
0 Kudos
Altera_Forum
Honored Contributor II
564 Views

I got the same issue with simple IORD/IOWR: 

 

=> Function '__builtin_stwio' could not be resolved 

 

I had to uncheck "Function is not resolved" option. 

 

Strange thing about it, the error only pops up in C++ projects, not C.
0 Kudos
Altera_Forum
Honored Contributor II
564 Views

This is a strange error, as the file is correctly compiled with __VERSION__ = "4.1.2" even though it is marked as an error in the editor. 

So it is the background code analysis program that marks it as an error, not the compiler. 

 

A way to disable just this symbol resolved error is to add the following code.  

 

# ifndef __VERSION__ 

# define __VERSION__ "x.x.x" 

# endif 

 

__VERSION__ will still be 4.1.2
0 Kudos
Altera_Forum
Honored Contributor II
564 Views

For me this Problem was solved, by turning of the plug-in "Codan Analysis UI for C/C++". You can find this option under: Window => Preferences => General => Startup and Shutdown 

 

This is a new tool introduced and automatically selected from Nios SBT Version 12.1 onwards, which makes sense as I didn't have this Problem with earlier Versions. 

 

Hope this helps for others too :)
0 Kudos
Altera_Forum
Honored Contributor II
564 Views

This has more to do with the EDS so I'll move this thread to that forum.

0 Kudos
Reply