JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


The Renesas Compiler Models



Overview

CodeSonar provides four Renesas compiler models.

Compiler
model
Modeled native compiler Source file extensions Description
ccrx ccrx any, including no file extension Renesas C/C++ compiler for RX Family
ch38 ch38 .c, .C, .i, cc, cpp, cxx, c++, ii Renesas C/C++ compiler for H8S, H8/300 Series
shc shc .c, .C, .i, cc, cpp, cxx, c++, ii Renesas C/C++ compilers for the SuperH RISC engine family.

Before version 5.0, shc compiled source files as C and shcpp compiled source files as C++. From version 5.0, shc switches language based on source file suffix (and shcpp is no longer documented, but is still available).

If you are using a pre-5.0 Renesas SuperH compiler, you will need to use a special-format ABI key to instruct the shc compiler model to treat source files as C.

shcpp shcpp .c, .C, .i, cc, cpp, cxx, c++, ii

Availability

Platform Availability The ccrx, ch38, shc, and shcpp compiler models are available as follows.
ch38, shc, and shcpp all platforms
ccrx Windows only
Default Recognition/Handling By default, compilations are recognized and handled as follows.
Platform Native Compiler Model Used
All ch38(.exe) ch38
All shc(.exe) shc
All shcpp(.exe) shcpp
Windows only ccrx.exe ccrx
Specifying Additional Mappings If your compiler executable has a different name, specify a corresponding COMPILER_MODELS rule to map your executable name to the ccrx, ch38, shc, or shcpp model.

For full details of all native compilers recognized by CodeSonar by default, see section Compilers Recognized by CodeSonar.

Model-Specific ABI Key Format

The ch38, shc, and shcpp compiler models all share the same ABI key format; the ccrx model has its own separate format.

ABI key format for ccrx compiler model

The model-specific ABI key format for the ccrx compiler model is:

<major_version>.<minor_version>.<patch_version>[.<user_string>]

as

decimalnum.decimalnum.decimalnum[.string]

If an ABI key with this format is specified for a compilation that is modeled with one of these compiler model, the following settings will be applied.

ABI key format for ch38, shc, and shcpp compiler models

The model-specific ABI key format for the ch38, shc, and shcpp compiler models is:

<Hitachi_version>.<Renesas_version>.<force_shc_C>[.<user_string>]

as

hexnum.hexnum.{0,1}[.string]

If an ABI key with this format is specified for a compilation that is modeled with one of these compiler model, the following settings will be applied.

Example

Suppose we are want to instruct the shc compiler model to treat source files as C, and to specify that both Renesas version and Hitachi version are 0x602. Then we add the following rule to the configuration file.

COMPILER_MODELS += /path/to/shc.exe -> shc:0x602.0x602.1

For more information, see Compiler Models: ABI Keys.

Command Arguments

The following tables list options that receive additional treatment in the Renesas compiler models. Options not mentioned in this section are ignored.

Argument Alias
(except ccrx)
Additional Treatment in Model

All Renesas Models

  -define=m[,m2,...] -def Defines macro m (m2,...) to 1.
-define=m=def[,m2=def2,...] -def
Defines macro m with def as its definition (m2 with def2 as its definition, ...).
-endian=val -en
ch38, shc, shcpp If val is l or little, defines macro _LIT. In all other cases, defines macro _BIG.
ccrx If val is big, defines macro _BIG. If val is little or this flag is not specified, defines macro _LIT. If val has any other value, CodeSonar will not build a project or generate any internal representation.
-exception -ex Specifies front end option --exceptions unless the command line subsequently contains -noex, /noex, -noexception, or /noexception. (In all other cases, specifies --no_exceptions.)
The ccrx model also specifies front end option --no_exceptions if both -exception and -lang=ecpp are specified.
-include=dlist -i For each directory dir in the comma-separated string dlist, specifies front end option -Idir.
-preinclude=dlist -prei For each directory dir in the comma-separated string dlist, specifies front end option --preincludedir.
-subcommand=file -su
-sub
Extracts the options specified in file and appends them to the command line.

ch38, shc and shcpp Models Only (i.e. not ccrx)

  -code=asm
-code=asmcode
-c Specifies front end option --asm_functions.
-double=val -do If val is f or float, defines macro __FLT__.

For SuperH compilers, also defines macro _FLT.

-dspc -ds Specifies front end options --add_named_address_space=__X, --add_named_address_space=__Y, and --cs_dspc, unless there is a subsequent occurrence of -ecpp.

For SuperH compilers, also defines macro _DSPC.

-ecpp -ec Specifies front end option --embedded_c++, unless there is a subsequent occurrence of -dspc.
-pack=val (n/a)
If val is nonempty, specifies front end option --pack_alignment val.
-sjis -sj Specifies front end options --multibyte_chars and --cs_sjis unless the command line subsequently contains one of the following:
(Super H and H8) -lat, /lat -latin1, /latin1
(Super H) -e, /e -euc, /euc
(H8) -eu, /eu -euc, /euc
-string=s -st
If s is d or data, specifies --no_const_string_literals. (In all other cases, specifies --const_string_literals.)
-template=timode
-t Specifies front end option --instantiate mode where mode is:
none if timode is n or none,
local if timode is s or static,
used if timode is u or used,
all if timode is al or all,
used otherwise.

ccrx Model Only

  -auto_enum   Defines macro __AUTO_ENUM=1.
-big5   Specifies front end option --multibyte_chars unless the command line subsequently contains -utf8.
-bit_order=val   If val is left, defines macro __BITLEFT=1.
If val is right, or this flag is not specified, defines macro __BITRIGHT=1.
If there are multiple -bit_order settings, only the last one applies.
-cpu=val   If val is rx200, defines macro __RX200=1
If val is rx600, defines macro __RX600=1.
If there are multiple -cpu settings, only the last one applies.
If both -cpu and -isa are specified, CodeSonar will not build a project or generate any internal representation.
If both -cpu=rx200 and -fpu are specified, CodeSonar will not build a project or generate any internal representation.
-dbl_size=val   If val is 8, defines macro __DBL8=1 and specifies front end options --cs_targ_sizeof_double 8 and --cs_targ_sizeof_long_double 8.
If val is 4, or this flag is not specified, defines macro __DBL4=1 and specifies front end options --cs_targ_sizeof_double 4 and --cs_targ_sizeof_long_double 4.
If there are multiple -dbl_size settings, only the last one applies.
If val has any other value, CodeSonar will not build a project or generate any internal representation.
-denormalize=val   If val is on, defines macro __DON=1.
If val is off, or this flag is not specified, defines macro __DOFF=1.
If there are multiple -denormalize settings, only the last one applies.
-euc   Specifies front end option --multibyte_chars unless the command line subsequently contains -utf8.
-fpu   Unless there is a subsequent occurrence of -nofpu:
  • If -cpu=rx600 is specified, defines macro __FPU=1.
  • If -cpu=rx200 is specified, CodeSonar will not build a project or generate any internal representation.
  • If -isa=rxv1 or -isa=rxv2 is specified, defines macro __FPU=1.
(Note that at most one of these cases can occur.)
-gb2312   Specifies front end option --multibyte_chars unless the command line subsequently contains -utf8.
-isa=val   If val is rxv1, defines macro __RXV1=1.
If val is rxv2, defines macro __RXV2=1.
If there are multiple -isa settings, only the last one applies.
If both -cpu and -isa are specified, CodeSonar will not build a project or generate any internal representation.
-int_to_short   Defines macro __INT_SHORT=1 and specifies front end option --cs_targ_sizeof_int 2.
-lang=val   If val is c, compiles as C (regardless of file extension) and defines macro __STDC_VERSION__=199409L.
If val is c99, compiles as C (regardless of file extension) and specifies front end option --c99.
If val is cpp, compiles as C++ (regardless of file extension).
If val is ecpp, compiles as C++ (regardless of file extension) specifies front end option --embedded_c++
If there are multiple -lang settings, only the last one applies.
-latin1   Specifies front end option --multibyte_chars unless the command line subsequently contains -utf8.
-library=val   If val is function, defines macro __FUNCTION_LIB=1.
If val is intrinsic, or this flag is not specified, defines macro __INTRINSIC_LIB=1.
If there are multiple -library settings, only the last one applies.
If val has any other value, CodeSonar will not build a project or generate any internal representation.
-nofpu   Cancels the effect of a previous occurrence of -fpu.
-nouse_pid_register   No effect unless -pid is also specified, in which case CodeSonar will not build a project or generate any internal representation.
-pack
Specifies front end option --pack_alignment 1 unless the command line subsequently contains -unpack.
-pic   Defines macro __PIC=1.
-pid
-pid=val
  Defines macro __PID=1 unless -nouse_pid_register is also specified, in which case CodeSonar will not build a project or generate any internal representation.
-round=val   If val is zero, defines macro __ROZ=1.
If val is nearest, or this flag is not specified, defines macro __RON=1.
If there are multiple -round settings, only the last one applies.
-rtti=val   If val is on, specifies front end option --rtti unless -lang=ecpp is also specified.
If val is on but -lang=ecpp is also specified, specifies front end option --no_rtti .
If val is off, or this flag is not specified, specifies front end option --no_rtti.
If there are multiple -rtti settings, only the last one applies.
-signed_bitfield   Defines macro __SBIT=1 and specifies front end option --signed_bit_fields, unless the command line subsequently contains -unsigned_bitfield.
-signed_char   Defines macro __SCHAR=1 and specifies front end option --signed_chars, unless the command line subsequently contains -unsigned_char.
-sjis   Specifies front end option --multibyte_chars unless the command line subsequently contains -utf8.
-subcommand=fname    Read additional arguments out of file fname and append to the argument list for processing.
-undefine=m[,m2,...]   Undefines macros m (m2,...).
-unpack   Cancels the effect of a previous occurrence of -pack.
-unsigned_bitfield   Defines macro __UBIT=1 and specifies front end option --unsigned_bit_fields, unless the command line subsequently contains -signed_bitfield.
-unsigned_char   Defines macro __UCHAR=1 and specifies front end option --unsigned_chars, unless the command line subsequently contains -signed_char.
-utf8    Specifies front end option --unicode_source_kind UTF-8 unless the command line subsequently contains -sjis, -euc, -latin1, -big5, or -gb2312.

ch38 Model Only

  -abs16 (n/a) Defines macro __ABS16__.
-byteenum -b Specifies front end option --short_enums and defines macro __BENM__.
-cpu=mode[:bitw][:md] -cp Defines several macros. Click a macro name for information about its definition.
-cpuexpand[=val] -cpue Defines macro __CPUEX__.
-lang=val -lan Sets compilation mode to C if val is c, C++ otherwise (including c99). If val is val, also defines macro __STDC_VERSION__=199901L.
-library=ltype -lib If ltype is i or intrinsic, defines macro __INTRINSIC_LIB__.
-pack=val -pa
Specifies front end option --pack_alignment val.
-ptr16 (n/a) Defines macro __DATA_ADDRESS_SIZE__ to 2.
-rtti=on -rt Specifies front end option --rtti. (In all other cases, specifies --no_rtti.)
-ws=file (n/a) Extracts the options specified in file and appends them to the command line.

shc and shcpp Models Only

  -auto_enum -au Specifies front end option --short_enums.
-cpu=mode -cp Defines macro _MODE, where MODE is the upper-case version of mode.
-denormalize=on -den Defines macro _DON.
-fixed_const -fixed_c Defines macro _FXD.
-fpu=val -fp If val is s or single, defines macro _FPS.

If val is d or double, defines macro _FPD.

-lang=val -la Sets compilation mode to C if val is c, C++ otherwise (including c99).
-pic=1 -p Defines macro _PIC.
-round=val -r If val is n or nearest, defines macro _RON.
-rtti=on (n/a) Specifies front end option --rtti. (In all other cases, specifies --no_rtti.)

No CodeSonar Build

If any of the following are specified, CodeSonar will ignore the compilation and will not generate any corresponding internal representation. If a CodeSonar project is based only on ignored compilations, it will have no contents and so will not be finalized.

ch38, shc, shcpp ccrx
-prep (/prep, -preprocessor, /preprocessor) -output=outputtype[=filename] for any outputtype except src, obj, abs, hex, or sty
n/a Both -cpu and -isa are specified.
n/a Neither -cpu nor -isa is specified.
n/a Both -cpu=rx200 and -fpu are specified.
n/a Both -pid and -nouse_pid_register are specified.
n/a -endian=val for any val except big, little
n/a Any ccrx-only flag is specified with an argument other than those explicitly noted in the table above.

Compilation Mode

The modeled compilation mode depends on the modeled build command and the special-format ABI key associated with the compilation (if any).

Predefined Macros

The Renesas compiler models define the following macros in addition to the standard CodeSonar predefined macros.

ccrx Macros

Always Defined
__EDG__ = 1
__EDG_VERSION__ = An integral value that encodes the version number of the EDG C front end used by the model. If the front end version is MAJOR.MINOR, the value is MAJOR*100+MINOR.
__STDC__ = 1
__RENESAS_VERSION__ = The value derived from the special-format ABI key associated with the compilation, or 0x0602 if there is no such key.
   
Conditionally Defined
__AUTO_ENUM =1 when -auto_enum is specified.
__BITLEFT =1 when -bit_order=left is specified.
__BITRIGHT =1 when -bit_order=right is specified, or -bit_order is not specified.
__DBL4 =1 when -dbl_size=4 is specified, or -dbl_size is not specified.
__DBL8 =1 when -dbl_size=8 is specified.
__DOFF =1 when -denormalize=off is specified, or -denormalize is not specified.
__DON =1 when -denormalize=on is specified.
__FPU =1 when -cpu=rx600, -isa=rxv1, or -isa=rxv2 is specified.
__FUNCTION_LIB =1 when -library=function is specified.
__INT_SHORT =1 when -int_to_short is specified.
__INTRINSIC_LIB =1 when -library=intrinsic is specified, or -library is not specified.
__PID =1 when -pid is specified.
__PIC =1 when -pic is specified.
__RON =1 when -round=nearest is specified.
__ROZ =1 when -round=zero is specified, or -round is not specified.
__RX200 =1 when -cpu=rx200 is specified.
__RX600 =1 when -cpu=rx600 is specified.
__RXV1 =1 when -isa=rxv1 is specified.
__RXV2 =1 when -isa=rxv2 is specified.
__SBIT =1 when -signed_bitfield is specified.
__SCHAR =1 when -signed_char is specified.
__STDC_VERSION__=199901L when -lang=c is specified, or -lang is not specified.
__UBIT =1 unless -signed_bitfield is specified.
__UCHAR =1 unless -signed_char is specified.

ch38 Macros

Always Defined
__EDG__ = 1
__EDG_VERSION__ = An integral value that encodes the version number of the EDG C front end used by the model. If the front end version is MAJOR.MINOR, the value is MAJOR*100+MINOR.
__entry(...) =
__global_register(r) =
__H8__
__HITACHI__
__HITACHI_VERSION__ = The value specified in the special-format ABI key associated with the compilation, or 0x0602 if there is no such key.
__indirect(...) =
__indirect_ex(...) =
__interrupt(...) =
__RENESAS__
__RENESAS_VERSION__ = The value specified in the special-format ABI key associated with the compilation, or 0x0602 if there is no such key.
Conditionally Defined
__MODE__ when -cpu=mode[:bw][:md] is specified. MODE is the upper-case version of mode.
__ADDRESS_SPACE__ when -cpu=mode[:bw][:md] specified. Defined to bw (a number) if it is specified, otherwise definition depends on mode:
16 if mode in {h8sxn, 2600n, 2000n, 300hn, 300, 300l}
24 if mode in {h8sxm, h8sxa, 2600a, 2000a, 300ha, ae5}
32 if mode =h8sxx
16 otherwise
__ABS16__ when -abs16 is specified.
__BENM__ when -byteenum (-b) is specified.
__CPUEX__ when -cpuexpand (-cpue) is specified.
__DATA_ADDRESS_SIZE__ when -cpu=mode[:bw][:md] is specified. Definition depends on mode and whether or not -ptr16 (-pt) is specified:
4 if -ptr16 is not specified and mode in {300ha, 2000a, 2600a, h8sxa, h8sxx, ae5}
2 otherwise
__FLT__ when -double=f or -double=float is specified.
__HAS_DIVIDER__ when -cpu=mode[:bw]:d or -cpu=mode[:bw]:md is specified and mode begins with h8sx.
__HAS_MULTIPLIER__ when -cpu=mode[:bw]:m or -cpu=mode[:bw]:md is specified and mode begins with h8sx.
__INTRINSIC_LIB__ when -library=i or -library=instrinsic (-lib) is specified.
__STDC_VERSION__=199901L when -lang=c99 is specified.

shc and shcpp Macros

Always Defined
__EDG__ = 1
__EDG_VERSION__ = An integral value that encodes the version number of the EDG C front end used by the model. If the front end version is MAJOR.MINOR, the value is MAJOR*100+MINOR.
__HITACHI__  
__HITACHI_VERSION__ = The value specified in the special-format ABI key associated with the compilation, or 0x0901 if there is no such key.
__RENESAS__  
__RENESAS_VERSION__ = The value specified in the special-format ABI key associated with the compilation, or 0x0901 if there is no such key.
_SH  
Conditionally Defined
_MODE when -cpu=mode (-cp) is specified. MODE is the upper-case version of mode.
_BIG when -endian=l or -endian=little (-en) is not specified.
_DON when -denormalize=on (-den) is specified.
_DSPC when -dspc (-ds) is specified.
_FLT and __FLT__ when -double=f or -double=float (-do) is specified.
_FPD when -fpu=d or -fpu=double (-fp) is specified.
_FPS when -fpu=s or -fpu=single (-fp) is specified.
_FXD when -fixed_const (-fixed_c) is specified.
_LIT when -endian=l or -endian=little (-en) is specified.
_PIC when -pic=1 (-p) is specified.
_RON when -round=n or -round=nearest (-ro) is specified.

C Extensions: Renesas C/C++ compiler for SuperH RISC

This section describes the C language extensions supported by the Renesas C/C++ compilers for the SuperH RISC engine family (shc/shcpp), and the treatment of those extensions in the compiler models.

Types

Extension Fixed point data types:
  • __fixed
  • long__fixed
  • __accum
  • long__accum
Treatment Fixed point types supported by CodeSonar internal representation; literal fixed point values stored as float.

Memory Qualifiers

Extension Predefined memory qualifiers __X, __Y; users can add up to 5 additional named memory spaces.
Treatment Memory spaces not explicitly modeled. Use the --add_named_address_space front end option to add user-defined memory spaces.

Keywords

Extension Additional keywords
  • __sat
  • __circ
Treatment The compiler model scans and ignores these keywords.

Section Address Operators

Extension Additional keywords
  • __sectop
  • __secend
  • __secsize
Treatment The compiler model treats these keywords as function calls.

Nested Comments

Extension Nested comments are disallowed by default, but users can use nested comments if they specify command line option comment=nest or enable IDE option Allow comment nest.
Treatment The compiler model will issue a warning if -comment=nest occurs on the command line or Allow comment nest is enabled. If nested comments actually occur they will cause parse errors.

C Extensions: Renesas C/C++ compiler for H8S, H8/300 Series

The following table describes the C language extensions supported by the Renesas C/C++ compiler for the H8S, H8/300 Series (ch38), and the treatment of those extensions in the compiler model.

#pragma Extensions and Keywords

Extension
#pragma Extension Specifier Keyword
#pragma stacksize  
#pragma section  
#pragma abs8 section  
#pragma abs16 section  
#pragma indirect section  
#pragma abs8 __abs8
#pragma abs16 __abs16
  _near8
  _near16
  __ptr16
#pragma bit_order
#pragma interrupt __interrupt
#pragma entry __entry
#pragma indirect __indirect
  _indirectex
  __indirect_ex
#pragma inline __inline
#pragma regsave _regsave
#pragma noregsave _noregsave
  _regparam2
  _regparam3
#pragma option  
#pragma global_register _globalregister
#pragma pack 1  
#pragma pack 2  
#pragma unpack  
  __evenaccess
#pragma address  
* #pragma inline_asm  
* #pragma asm  
* #pragma endasm  
* __asm
Treatment The compiler model scans and ignores these extension specifiers and keywords except for those marked with an asterisk (*), which the model treats in the same way as the compiler.

Section Address Operators

Extension Additional keywords
  • __sectop
  • __secend
Treatment The compiler model treats these keywords as function calls.
 

To report problems with this documentation, please visit https://support.codesecure.com/.