本人c语言纯萌新一枚,编程环境是vscode+clang+mingw,安装的时候是直接把mingw的文件无冲突合并到LLVM里的,参照:http://www.javashuo.com/article/p-oqurwbmp-cy.html。html
今日在完成c语言老师布置的做业的时候写了如下代码:git
#include<stdio.h> #include<float.h> int main(void) { double dv = 1.0 / 3.0; float fv = 1.0 / 3.0; printf("%.4f %.4f\n", dv, fv); printf("%.12f %.12f\n", dv, fv); printf("%.16f %.16f\n", dv, fv); printf("%d %d\n", FLT_DIG, DBL_DIG);
return 0; }
结果很意外的是,不管是直接插件run code仍是F5编译均提示编译失败:github
In file included from exercises5.c:2: In file included from C:\Program Files\LLVM\lib\clang\9.0.0\include\float.h:31: C:\Program Files\LLVM\x86_64-w64-mingw32\include\float.h:28:15: fatal error: 'float.h' file not found
但是其余编译器彷佛并无这个问题,因而在谷歌娘搜到一个结果,大意为新版本的LLVM和旧版本mingw的float.h不兼容,致使二者没法共同发挥做用,须要把新的float.h合并过来编程
那么解决方案以下:es5
将这个网址中的内容所有复制后覆盖到LLVM\x86_64-w64-mingw32\include\下的float.h中,这样mingw中的float.h就和新版本clang的float.h兼容了。spa
那么如今问题就解决完毕了。 .c文件正确编译并输出了如下内容:插件
0.3333 0.3333 0.333333333333 0.333333343267 0.3333333333333333 0.3333333432674408 6 15
撒花~ *\(^ ▽ ^)/*code