Quantcast
Channel: Altera Forums
Viewing all articles
Browse latest Browse all 19390

sscanf and sprintf

$
0
0
1. Version 13.0 vs 12.1sp1

Recently we try the version 13.0 with our working software in 12.1sp1 but we have a surprise it was not working properly.
We have found why, it is because the compiler does not threat the structure and union address alignment the same way as the 12.1 (padding).
Me and Frédéric Fortin have try to find the release note for the compiler but nothing is available.
We try to use the "#pragma pack(2) " but without success.

So could we have a complete documentation about the gcc compiler version you use and have the release note of this one.

For now we come back to version 12.1sp1

2. sprintf vs sscanf

I try to use sprintf to serialise data to my memory (eeprom or flash) because structure and union are not threat the same way (see my previous coment).
So with sprintf I could format the output to my memory and be sure to have the same format even if your gcc compiler change and read it back with sscanf.
But my test was not so good. I try to use sprintf to generate my output stream for my memory and found that the format specifiers are not correctly threat as well for sscanf.

I also have some warning messages when I compile, why ?

warning: warning: close is not implemented and will always fail
warning: warning: lseek is not implemented and will always fail
warning: warning: read is not implemented and will always fail
warning: warning: write is not implemented and will always fail

For the test I have made with sprintf and sscanf, I put you in attachment the C code I use for my test (it is a text file).

Decimal Format
sprintf : The stream output is perfect
sscanf : the value read back are not good for Test_INT8 = 10 and Test_UINT8 = 0, it should be Test_INT8 = -10 and Test_UINT8 = 10

Hexadecimal Format
sprintf : The stream output is practically perfect, except for Test_INT8 because it generate an output of 4 character length (FFF6) and it should be (F6)
sscanf : the value read back are not good for Test_INT8 = 10 and Test_UINT8 = 0, it should be Test_INT8 = -10 and Test_UINT8 = 10

To have a reference for the formatting specifier

cplusplus.com/reference/cstdio/scanf/
cplusplus.com/reference/cstdio/printf/



Attached Files

Viewing all articles
Browse latest Browse all 19390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>