gcc“–;Werror:没有这样的文件;指的是目标还是Werror用法?

gcc“–;Werror:没有这样的文件;指的是目标还是Werror用法?,c,makefile,gnu-make,C,Makefile,Gnu Make,我正在努力学习本课程(),并遇到了一些编译问题 它建议使用gcc、make和下面的Makefile 我不知道我收到的错误消息是否与C源代码中的某些内容有关(似乎不太可能),或者与我配置gcc选项的方式有关 $ gcc-8 -v Using built-in specs. COLLECT_GCC=gcc-8 COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/8.1.0/libexec/gcc/x86_64-apple-darwin17.5.0/8.1.0/lto-

我正在努力学习本课程(),并遇到了一些编译问题

它建议使用gcc、make和下面的Makefile

我不知道我收到的错误消息是否与C源代码中的某些内容有关(似乎不太可能),或者与我配置gcc选项的方式有关

$ gcc-8 -v
Using built-in specs.
COLLECT_GCC=gcc-8
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/8.1.0/libexec/gcc/x86_64-apple-darwin17.5.0/8.1.0/lto-wrapper
Target: x86_64-apple-darwin17.5.0
Configured with: ../configure --build=x86_64-apple-darwin17.5.0 --prefix=/usr/local/Cellar/gcc/8.1.0 --libdir=/usr/local/Cellar/gcc/8.1.0/lib/gcc/8 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-8 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC 8.1.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls
Thread model: posix
gcc version 8.1.0 (Homebrew GCC 8.1.0)

$ gmake -v
GNU Make 4.2.1
Built for x86_64-apple-darwin17.0.0
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ cat Makefile
CC:=gcc-8
CFLAGS:=-O0 -g -std=c99 -Wall -Wextra -Wshadow -pedantic –Werror
CXXFLAGS:=-O0 -g -std=c++11 -Wall -Wextra -Wshadow -pedantic -Weffc++ -Werror

$ cat nothing.c
int main (void){
  return 0;
}

$ gmake nothing
gcc-8 -O0 -g -std=c99 -Wall -Wextra -Wshadow -pedantic –Werror    nothing.c   -o nothing
gcc-8: error: –Werror: No such file or directory
gmake: *** [<builtin>: nothing] Error 1
$gcc-8-v
使用内置规格。
收集\u GCC=GCC-8
COLLECT_LTO_WRAPPER=/usr/local/cillar/gcc/8.1.0/libexec/gcc/x86_64-apple-darwin17.5.0/8.1.0/LTO-WRAPPER
目标:x86_64-apple-darwin17.5.0
配置为://COMPUTION:Bug=X86Y64-Apple DARWIN 175.0前缀=/Ur/Prase/CyrAR/Gcc/0.1.0- LBDIR//Ur/Prime/CyrAR/Gcc/81.0/LIb/GCc/8-使能语言= C、C++、Objc、Obj-C++,fortran——程序后缀=-8——带gmp=/usr/local/opt/gmp——带mpfr=/usr/local/opt/mpfr——带mpc=/usr/local/opt/libmpc——带isl=/usr/local/opt/isl——带系统zlib——启用检查=发布——带pkgversion='Homebrew GCC 8.1.0'-带bugurl=https://github.com/Homebrew/homebrew-core/issues --禁用nls
线程模型:posix
gcc版本8.1.0(自制gcc 8.1.0)
$gmake-v
GNU Make 4.2.1
专为x86_64-apple-darwin17.0.0构建
版权所有(C)1988年至2016年自由软件基金会。
许可证GPLv3+:GNU GPL版本3或更高版本
这是自由软件:您可以自由更改和重新发布它。
在法律允许的范围内,不存在任何担保。
$cat生成文件
CC:=gcc-8
CFLAGS:=-O0-g-std=c99-墙壁-Wextra-Wshadow-学究式-Werror
CXXFLAGS:=-O0-g-std=c++11-Wall-Wextra-Wshadow-pedantic-Weffc++-Werror
$cat nothing.c
内部主(空){
返回0;
}
$gmake什么都不做
gcc-8-O0-g-std=c99-Wall-Wextra-Wshadow-pedantic-Werror nothing.c-o nothing
gcc-8:错误:-错误:没有这样的文件或目录
gmake:**[:无]错误1

这里的问题是,在makefile中,
Werror
前面的破折号不是标准破折号,而是unicode破折号(代码8211)

如果仔细观察,长度略有不同。有时文字处理程序或电子邮件客户端出于某些表面原因切换破折号

结果是,选项解析器将其视为一个文件,而不是一个选项,并尝试打开它进行编译

当您知道:在
CFLAGS
中使用正确的破折号(破折号在
CPPFLAGS
中是正常的)时,解决方法是显而易见的:


这就解决了。。。我只是从页面上复制粘贴的内容。我想下次我应该手动输入吗?你是不是通过看它才发现的?是的,也是因为我知道它应该有用。如果你问我的话,应该有人向他们报告。打得好。我只是用开放式课程反馈页面来报告。
-pedantic –Werror
-pedantic -Werror