mingw compiler problem with printf/scanf formats
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| EPICS Base |
Low
|
Unassigned |
Bug Description
../db/dbJLink.c: In function ‘dbjl_integer’:
../db/dbJLink.
^
../db/dbJLink.
It seems that mingw does not like "%lld".
Dirk Zimoch (dirk.zimoch) wrote : | #1 |
Dirk Zimoch (dirk.zimoch) wrote : | #2 |
Dirk Zimoch (dirk.zimoch) wrote : | #3 |
Dirk Zimoch (dirk.zimoch) wrote : | #4 |
FYI: I used Ralph's new .ci features on Travis with configurations like this:
- env: BASE=7.0 WINE=32 TEST=NO STATIC=YES
compiler: mingw
- env: BASE=7.0 WINE=64 TEST=NO STATIC=NO
compiler: mingw
summary: |
- mingw compiler problem in dbJLink.c + mingw compiler problem with printf/scanf formats |
Martin Konrad (info-martin-konrad) wrote : | #5 |
Have you tried something like the following?
printf(
You might need to include <inttypes.h>. Also see https:/
Dirk Zimoch (dirk.zimoch) wrote : | #6 |
Martin, none of that is my code. I just noticed it when testing something completely different.
Andrew Johnson (anj) wrote : | #7 |
We've been seeing this warning for a long time but haven't known about a fix for it. From the links you posted it would appear that adding the flag -D__USE_
/usr/bin/
../testpdb.cpp: In function 'int main(int, char**)':
../testpdb.
../testpdb.
../testpdb.
../testpdb.
../testpdb.
../testpdb.
My gcc cross-compiler is from RHEL-7, so maybe it might still help with a newer gcc/MinGW version:
tux% x86_64-
x86_64-
If someone sees that it does help on newer versions I can add that flag to 3.15.
Changed in epics-base: | |
status: | New → Triaged |
importance: | Undecided → Low |
mdavidsaver (mdavidsaver) wrote : | #8 |
I admit that I'm responsible for spreading this through the PVA code. I knew that recent windows and WINE both handle the standard "%lld" spec., and assumed that this was just mingw legacy. (historically MSVC used "%I64d") However, I hadn't considered the existence of a compiler builtin.
mdavidsaver (mdavidsaver) wrote : | #9 |
An old, incomplete patch against pvDataCPP investigating portability issues of using PRIx64 and friends. Might be of interest, or not.
Dirk Zimoch (dirk.zimoch) wrote : | #10 |
I have now installed mingw on my local PC (RHEL-7)
gcc version 4.9.3 20150626 (Fedora MinGW 4.9.3-1.el7) (GCC)
I see the format problem here as well and adding -D__USE_
So I wrote at test program that uses those offending formats, compiled it with mingw 32 and 64 bit and run it on Windows 10. No problem. Formats are interpreted correctly.
So it seems that "only" the warnings are wrong. I suggest to add -Wno-format to the mingw configurations to silence the warnings (optimally dependent on the mingw version but that is a bit hard to do -- and has some overhead cost).
Also here:
../yajl/yajl_gen.c yajl_gen. c:205:16: warning: unknown conversion type character ‘l’ in format [-Wformat=] yajl_gen. c:205:16: warning: too many arguments for format [-Wformat- extra-args]
../yajl/yajl_gen.c: In function ‘yajl_gen_integer’:
../yajl/
sprintf(i, "%lld", number);
^
../yajl/
and in several locations in dbUnitTest.c, lnkConst.c, lnkCalc.c line 131, lnkDebug.c line 112, testTimeStamp.cpp lines 36 and 52, lazycounter.cpp line 172.
Also "%zu" does not work in testPVData.cpp:
../../testApp/ pv/testPVData. cpp: In function ‘void testSizes()’: pv/testPVData. cpp:43: 58: warning: unknown conversion type character ‘z’ in format [-Wformat=]
^ pv/testPVData. cpp:44: 5: note: in expansion of macro ‘SHOW’ sport.cpp:
../../testApp/
#define SHOW(T) testDiag("sizeof(" #T ")==%zu", sizeof(T))
../../testApp/
SHOW(Field);
^
and in blockingUDPTran
In file included from ../../src/ remote/ blockingUDPTran sport.cpp: 29:0: remote/ blockingUDPTran sport.cpp: In member function ‘bool epics:: pvAccess: :BlockingUDPTra nsport: :send(const char*, size_t, const osiSockAddr&)’: utils/pv/ logger. h:48:73: warning: unknown conversion type character ‘z’ in format [-Wformat=]
^ remote/ blockingUDPTran sport.cpp: 437:9: note: in expansion of macro ‘LOG’
LOG(logLevelD ebug, "UDP Tx (%zu) %s -> %s.",
../../src/
../../src/
#define LOG(level, format, ...) pvAccessLog(level, format, ##__VA_ARGS__)
../../src/
^
as well as in transportRegist ry.cpp line 48, codec.cpp line 1610, responseHandler s.cpp line 2029, pvlist.cpp several lines, testpdb.cpp line 310.
It seems we have a problem with mingw.