IBM Support

Error: ISO C forbids an empty source file.

Troubleshooting


Problem

C models can be compiled using compilers options that adhere to strict ISO C compliance. For instance, when using a Cygwin C compiler with the -pedantic-errors option, an error may occur stating a source file is empty.

Cause

This error will occur when building a library or executable that does not rely on the C TargetRTS. When the C TargetRTS is used, the component header file is non-empty and since every element the component references has a inclusion to the component header file, each element's source is non-empty.
#define A 0x0001
#define C 0x0002

/* implementation file */
#include <DefinedVars.h>

2) Empty Component - Since the component does not reference the C TargetRTS, the compiler will see it's header and implementation files as empty.

Resolving The Problem

1) Empty Class - This is not a toolset problem since the same class can be created outside of Rose RealTime and the same error will occur when compiling using strict ISO C compliance. The solution is to add something to the class that will cause the compiler to see it as non-empty. For example, (i.e. int x = 0;) could be added to the class specification --> C tab, in the HeaderPreface field.

/* header file DefinedVars.h*/
int x = 0;


#define A 0x0001
#define C 0x0002

2) Empty Component - If all the elements the component references are non-empty, an error will still occur stating the <component_name>.c file is empty. There are two workarounds for this problem.

a) Add something to the component specification --> C tab, in the CommonPreface field (i.e. int y = 1;). This is not so elegant since every element the component references and the component itself has a variable y, even if the elements were non-empty.

b) Open the component specification --> C Generation tab, and check the SingleDataCompilationUnit check box. This causes the component's implementation file to include the implementation files for all the elements it references and the result is the file is no longer empty.





[{"Product":{"code":"SSSHKL","label":"Rational Rose RealTime"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"2003","Edition":"Advanced","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

More support for:
Rational Rose RealTime

Software version:
2003

Document number:
578603

Modified date:
16 June 2018

UID

swg21167473