Comments (6)
Hello,
LodePNG is designed to work with C90. I don't get this warning with "gcc lodepng.c --ansi --pedantic -W -Wall -Wextra".
Could you please let me know which compiler flags you are using, and your gcc version (gcc -v), then I can try to reproduce it.
Thanks a lot for your help!
-Lode
from lodepng.
Hi!
"-c -Wall -O2 -pedantic -Wextra -Wall"
"-O2" enables this warning in that flags combination.
First got this error on Windows, CodeBlocks 13.12, and old GCC packeged in.
Now I reproduced it in Arch Linux with latest gcc:
$ gcc -v
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Целевая архитектура: x86_64-unknown-linux-gnu
Параметры конфигурации: /build/gcc/src/gcc-4.9-20150204/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release
Модель многопоточности: posix
gcc версия 4.9.2 20150204 (prerelease) (GCC)
from lodepng.
Interesting. LodePNG has some code inside of an #ifdef __cplusplus, and that code uses "//" style comments. Normally a C compiler is not even supposed to see that code.
Also, this warning appears when using the -pedantic flag but not using the -ansi or -std=c89 flag. So if you add -std=c89 or -ansi, it works without the warning. Is that an acceptable solution for you?
I could also change the // to /* */ inside of the __cplusplus blocks, though I wonder if this isn't a gcc quirk...
from lodepng.
lodepng.h has a lot of "//" in C-block.
Why not replace all "//" to "/ * * /"? It is a minute of work, and all compilers supports "/ *" comments.
"-ansi" is good workaround for me, thanks.
from lodepng.
LodePNG is indeed intended to work with C89/C90 so I fully support fixing this if needed.
I can confirm that currently, there are no "//" comments in C-code, only in code behind __cplusplus or LODEPNG_COMPILE_CPP #ifdefs. Otherwise it would have triggered an error with -ansi.
However there is a subtle cause:
Apparently the C99 spec says that comments are parsed in the translation phase, before the preprocessor. C89/C90 on the other hand doesn't specify this.
So maybe without the -std=c89 or -ansi flag, it is processing the comments first and triggering that warning (a warning that ironically is about C90), while with that flag, it does the preprocessor first...
In any case, maybe this does warrant changing the // comments to /**/ inside the C++ blocks. Sadly that ruins the C++ codestyle of those blocks a little bit... I'll see.
Note that the clang compiler, having the same interface as gcc, never warns about this even with "-c -Wall -O2 -pedantic -Wextra -Wall".
Here is a minimal piece of code that shows the gcc behaviour:
int main() {
return 0;
}
#ifdef __cplusplus
// C++ style comment in __cplusplus #ifdef
#endif
Thanks a lot for pointing this out!
from lodepng.
Changed all comments.
from lodepng.
Related Issues (20)
- sdl2 HOT 6
- vulnerability Discover HOT 2
- what's mean of this define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS and when should i define it
- code optimization
- Че за хрень 64 бит компиляция HOT 1
- Sudden increase in build size HOT 1
- Memory leaks in function benchmark.
- SEGV on unknown address in function pngdetail. HOT 2
- How to get a JSON string from the encoded image ? HOT 3
- Expected speed? HOT 6
- Fix warnings: `conversion from 'size_t' to 'unsigned short', possible loss of data` HOT 2
- chunk type is restricted to the decimal values 65 to 90 and 97 to 122
- Veracode discovered a race condition
- Consideration for changing the License to public domain
- allocate "reserved_size" extra memory
- Lodepng fails to open valid png image HOT 4
- Clarification on "filter_palette_zero"
- lodepng crashes ntdll.dll
- Encoding from RGB 24 frame buffers handling stride / pitch
- Think the custom_zlib api is incomplete. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lodepng.