Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

many complie warnings when run gcc -o c4 c4.c #77

Open
l1t1 opened this issue Dec 10, 2023 · 4 comments
Open

many complie warnings when run gcc -o c4 c4.c #77

l1t1 opened this issue Dec 10, 2023 · 4 comments

Comments

@l1t1
Copy link

l1t1 commented Dec 10, 2023

root@localhost:~# gcc -o c4 c4.c
c4.c: In function ‘next’:
c4.c:56:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   56 |         printf("%d: %.*s", line, p - lp, lp);
      |                 ~^         ~~~~                                                               |                  |         |
      |                  int       long long int
      |                 %lld
etc

my gcc version

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/11/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
root@localhost:~#
@l1t1
Copy link
Author

l1t1 commented Dec 10, 2023

try do as #64 said
if comment out #define int long long

c4.c: In function ‘next’:
c4.c:56:23: warning: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 3 has type ‘long int’ [-Wformat=]
   56 |         printf("%d: %.*s", line, p - lp, lp);
      |                     ~~^~         ~~~~~~
      |                       |            |
      |                       int          long int                                             c4.c:77:39: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   77 |         if (tk == id[Hash] && !memcmp((char *)id[Name], pp, p - pp)) { tk = id[Tk]; return; }
      |

@erikaemma
Copy link

The c4 compiled successful. But when I run it, Segment failed

@ArthurZhou
Copy link

The c4 compiled successful. But when I run it, Segment failed

use 32bit mode when compiling with gcc

@Lro-Steven-aq
Copy link

Lro-Steven-aq commented Aug 4, 2024

The c4 compiled successful. But when I run it, Segment failed

you should use tdm-gcc, instead of mingw or mingw-64 (your system is linux, i am not sure tdm-gcc support MS Windows)
img

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants