c4 icon indicating copy to clipboard operation
c4 copied to clipboard

many complie warnings when run `gcc -o c4 c4.c`

Open l1t1 opened this issue 1 year ago • 4 comments

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 avatar Dec 10 '23 13:12 l1t1

try do as https://github.com/rswier/c4/issues/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; }
      |

l1t1 avatar Dec 10 '23 14:12 l1t1

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

erikaemma avatar Jan 05 '24 07:01 erikaemma

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

use 32bit mode when compiling with gcc

ArthurZhou avatar Mar 21 '24 10:03 ArthurZhou

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

Lro-Steven-aq avatar Aug 04 '24 12:08 Lro-Steven-aq