Question & Answer
Question
How to resolve the ERROR 274 Compile and link exited with error code when using snprintf function within #CODE
Cause
The binaries included in the distribution of the SDL and TTCN Integrated Simulator were built using the C compilers .NET and the function is called _snprintf as opposed to snprintf in .NET, hence the linker error.
You will encounter the below linker error when the function snprintf is used within the #CODE block of a process/procedure in an SDL system:
link -nologo @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\nmFA.tmp
test_system_01_smc.obj : error LNK2019: unresolved external symbol _snprintf referenced in function _yPAD_z01_test_process_01
test_system_01_smc.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\link.EXE"' : return code '0x460'
Stop.
1: ERROR 274 Compile and link exited with error code
Compile and link completed
Answer
This can be resolved by replacing the occurrence of snprintf(...) to _snprintf(...) in the #CODE.
Attached is a sample example system that depicts the correct way of using the function snprintf.
Was this topic helpful?
Document Information
More support for:
Rational SDL Suite
Software version:
6.3
Operating system(s):
Windows
Document number:
130205
Modified date:
23 June 2018
UID
swg21408870