Last active
November 12, 2017 17:44
-
-
Save DavidEGrayson/1e9b0f9f4ced4d2c69b55a962fdb757b to your computer and use it in GitHub Desktop.
This code does not compile using mingw-w64 gcc in MSYS2 (and probably not in any version of gcc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat somefile.h | |
struct a; | |
struct a *init(); | |
void setd(struct a*p, int dd); | |
int getd(struct a*p); | |
void cleanup(struct a*p); | |
$ cat somefile.c | |
struct a { | |
int d; | |
}; | |
struct a *init(){ | |
return malloc(sizeof(struct a)); | |
} | |
void setd(struct a *p, int dd){ | |
p->d= dd; | |
} | |
int getd(struct a *p){ | |
return p->d; | |
} | |
void mfree(struct a *p){ | |
free(p); | |
} | |
$ cat myFile.c | |
#include "someFile.h" | |
int main(){ | |
struct a* d[2]; | |
d[0]= init(); | |
d[1]= init(); | |
struct a* pp = d[0]; | |
pp+=1; // thisis pointer arithmetic. | |
//getd(pp); will return d[1]'s value. | |
} | |
$ gcc -v | |
Using built-in specs. | |
COLLECT_GCC=D:\msys64\mingw64\bin\gcc.exe | |
COLLECT_LTO_WRAPPER=D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe | |
Target: x86_64-w64-mingw32 | |
Configured with: ../gcc-7.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld | |
Thread model: posix | |
gcc version 7.2.0 (Rev1, Built by MSYS2 project) | |
$ gcc myFile.c somefile.c -o testrun -Wall | |
myFile.c: In function 'main': | |
myFile.c:8:5: error: invalid use of undefined type 'struct a' | |
pp+=1; // thisis pointer arithmetic. | |
^~ | |
somefile.c: In function 'init': | |
somefile.c:6:12: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration] | |
return malloc(sizeof(struct a)); | |
^~~~~~ | |
somefile.c:6:12: warning: incompatible implicit declaration of built-in function 'malloc' | |
somefile.c:6:12: note: include '<stdlib.h>' or provide a declaration of 'malloc' | |
somefile.c: In function 'mfree': | |
somefile.c:18:5: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration] | |
free(p); | |
^~~~ | |
somefile.c:18:5: warning: incompatible implicit declaration of built-in function 'free' | |
somefile.c:18:5: note: include '<stdlib.h>' or provide a declaration of 'free' | |
david@URANIUM MINGW64 ~/Documents/scraps/crap | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment