Opened 10 years ago
Last modified 9 years ago
#3289 assigned defect
FMU compilation (MSVC) fails for big models
Reported by: | Owned by: | Adrian Pop | |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | FMI | Version: | trunk |
Keywords: | Cc: |
Description
Using flag +target=msvc, the following is observed when creating an FMU from a model with a very long modelDescription.xml file (the contents of which are also stored in a .c file).
mymodel_init.c(1) : error C2026: string too big, trailing characters truncated
mymodel_info.c(1) : error C2026: string too big, trailing characters truncated
The same code will compile fine with gcc, due to the compiler specific nature of limits imposed on string literals. Turns out cl has a maximum limit of 16KB.
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
If you define OPENMODELICA_XML_FROM_FILE_AT_RUNTIME when compiling the C file then the _init.c and _info.c files are not included but are read at runtime.
However, depending on how the fmu is expanded by the tool that loads it the dll might not find these files. That's why we included them.
I guess for MSVC we would need to use something like xxd (we used that before) to encode the xml files for C inclusion. I'll give it a try.
comment:3 by , 9 years ago
Hm, the MSDN says "The maximum length of a string literal is 65535 bytes".
I wonder if this means we can do something like:
x = "max_string1" "max_string2" "max_string3";
I'll give it a try.
comment:5 by , 9 years ago
I've been trying various ways to fix this but I haven't got any success yet.
Have you tried with the C++ runtime using flags: +target=msvc +simCodeTarget=Cpp
Hello, has any progress been made on this item since it was posted?