编译Licode报错:ifndef header guard has wrong style

董光霁
2023-12-01

编译licode git上的master的时候,一切都很顺利,但下载release中的压缩包,解压并编译,当编译到erizoAPI的时候却报了很多相同的错误,都是说头文件的风格不对,错误如下:

MediaStream.h:2:  #ifndef header guard has wrong style, please use: _HOME_TOPSLUO_WORKSPACE_TEST_LICODE_PRE_V7_14_ERIZOAPI_MEDIASTREAM_H_  [build/header_guard]

后来通过查找编译脚本发现,在cpplint.py中找到一个参数:

--root=subdir
  The root directory used for deriving header guard CPP variable.
   By default, the header guard CPP variable is calculated as the relative path
    to teh directory that contains .git, .hg, or .svn, When this flag is specified, the relative 
    path is calculated from the specified directory. If the specified directory does not exist, 
    this flag is ignored.
    Examples:
    No flag => CHROME_BROWSER_UI_BROWSER_H_
    --root=chrome => BROWSER_UI_BROWSER_H_
    --root=chrome/browser => UI_BROWSER_H_

也就是说,如果当前目录下存在.git或者.svn等目录,root参数是会计算出来参数,否则–root参会被忽略掉,那就会出现开头说的错误。

问题正是如此,因为从master中clone下来的源码存在.git目录,而解压压缩包的源码中不存在.git目录,所以在调用cpplint.py的时候,可以指定–root参数来解决此问题,比如:

./cpplint.py --filter=-legal.copyright,-build/include --root=/home/topsluo/licode --linelength=120 *.cc *.h
 类似资料: