0

I want to use google cpplint.py in my project to check code style.

I created a project with directory tree:

~ # tree                                                                                                                                                                                                                  [10:15:53]
.
├── CMakeLists.txt
└── src
    ├── a.cpp
    ├── b.cpp
    ├── c.cpp
    ├── CMakeLists.txt
    └── cpplint.py

1 directory, 6 files

the ultimate purpose is to use a.cpp to build a dynamic link library a.so

the first layer CMakeLists.txt looks like:

cmake_minimum_required(VERSION 3.1)

SET(CMAKE_C_COMPILER "/usr/bin/gcc")
SET(CMAKE_CXX_COMPILER "/usr/bin/g++")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fPIC -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++17 -Wall -ggdb -fPIC -g -fopenmp")

project(lint_demo)

add_subdirectory(src core_src)

the src CMakeLists.txt is:

add_library(a SHARED a.cpp b.cpp c.cpp)

a.cpp is a simple class definition:

#include <bits/stdc++.h>
class A { 
 public:   
  A(){}
 void test(int a){}
};

b.cpp and c.cpp is a empty define:

class B{};

my cpplint.py can run well with:

python cpplint.py a.cpp

it will print out:

a.cpp:0:  No copyright message found.  You should have a line: "Copyright [year] <Copyright Owner>"  [legal/copyright] [5]
a.cpp:3:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
a.cpp:4:  Missing space before {  [whitespace/braces] [5]
a.cpp:5:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
Done processing a.cpp
Total errors found: 4

how can i use cpplint.py in my project so that it can check style automatically when i make?

could you help on this?

nick
  • 599
  • 1
  • 8

0 Answers0