Skip to content

Commit

Permalink
Makefiles are up to date for Apple LLVM version 8.1.0 (clang-802.0.42…
Browse files Browse the repository at this point in the history
…). Added CppUTestCompileFlags.mk so there is one place to go for CppUTest compiler flags.
  • Loading branch information
jwgrenning committed Sep 15, 2017
1 parent f97fd8b commit 6fd4a25
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 66 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ Debug
*.cache
*.user
RemoteSystemsTempFiles/*
*.sublime*

19 changes: 19 additions & 0 deletions CppUTestCompileFlags.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wno-unknown-warning-option
CPPUTEST_WARNINGFLAGS += -Wno-covered-switch-default
CPPUTEST_WARNINGFLAGS += -Wno-reserved-id-macro
CPPUTEST_WARNINGFLAGS += -Wno-keyword-macro
CPPUTEST_WARNINGFLAGS += -Wno-documentation
CPPUTEST_WARNINGFLAGS += -Wno-format-nonliteral
CPPUTEST_WARNINGFLAGS += -Wno-sign-conversion
CPPUTEST_WARNINGFLAGS += -Wno-pedantic
CPPUTEST_WARNINGFLAGS += -Wno-shadow
CPPUTEST_WARNINGFLAGS += -Wno-missing-field-initializers
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
CPPUTEST_CFLAGS += -Wall
CPPUTEST_CFLAGS += -Wstrict-prototypes
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wno-missing-prototypes
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ You should end up with this directory structure:
5) Build the examples

-------------
For gcc users
For gcc/clang users
-------------
Build all examples

Expand All @@ -72,6 +72,43 @@ cd /path/to/code/root/code-t0
make
```

### Warning problems with gcc/clang

With the compilers adding more and more static analysis, each compiler may issue warnings like this:

```
#undef __USE_MINGW_ANSI_STDIO
^
/path/to/tools/cpputest-3.8/include/CppUTest/CppUTestConfig.h:265:9: error: macro name
is a reserved identifier [-Werror,-Wreserved-id-macro]
#define __USE_MINGW_ANSI_STDIO 1
^
In file included from <built-in>:1:
/path/to//tools/cpputest-3.8/include/CppUTest/MemoryLeakDetectorNewMacros.h:58:9: error:
keyword is hidden by macro definition [-Werror,-Wkeyword-macro]
#define new new(__FILE__, __LINE__)
^
```

The `-Werror` flag tells the compiler to treat warning as errors, causing the compile to fail. You could turn that off, but before you do that, you can tell the compiler to not complain about specific errors.

For the two errors shown in the above error output, from the (cygwin,mongx, linux, mac) command line set the initial value for `CPPUTEST_WARNINGFLAGS` like this:

```
export CPPUTEST_WARNINGFLAGS="-Wno-reserved-id-macro -Wno-keyword-macro"
```

Notice that addong "no-" to the warning flags from the error output disables that warning. Generally this can be used to disable any new warning that comes up.

Run make again. Once you clear the warnings you should get a clean build. You could add this to `CppUTestCompileFlags.mk`.


### Unknown warnings in gcc/clang

If your compiler does not support some warning flag in the released makefiles, you can get an error about it. The `-Wno-unknown-warning-option` is in `CppUTestCompileFlags.mk`, but may not be supported. You'll need to comment out each flag the compiler complains about in `CppUTestCompileFlags.mk`.

-----------------
For eclipse users
-----------------
Expand Down
5 changes: 1 addition & 4 deletions SandBox/MakefileCppUTest.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ INCLUDE_DIRS =\
.\
$(CPPUTEST_HOME)/include\
$(PROJECT_HOME_DIR)/include/LedDriver\

#CPPUTEST_WARNINGFLAGS += -pedantic-errors -Wconversion -Wshadow -Wextra
CPPUTEST_WARNINGFLAGS += -Wall -Werror -Wswitch-default -Wswitch-enum


include ../CppUTestCompileFlags.mk
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
12 changes: 1 addition & 11 deletions code-t0/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,10 @@ PROJECT_HOME_DIR = .

CPP_PLATFORM = Gcc

CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wswitch-enum
CPPUTEST_WARNINGFLAGS += -Wno-documentation
CPPUTEST_CFLAGS += -Wextra
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wstrict-prototypes

SRC_DIRS = \
src/util\
src/HomeAutomation\


TEST_SRC_DIRS = \
tests \
tests/HomeAutomation\
Expand All @@ -38,5 +28,5 @@ INCLUDE_DIRS =\
include/*\
mocks


include ../CppUTestCompileFlags.mk
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
16 changes: 2 additions & 14 deletions code-t1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ TEST_TARGET = \
PROJECT_HOME_DIR = .
CPP_PLATFORM = Gcc

CPPUTEST_USE_EXTENSIONS = Y
CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wswitch-enum
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
CPPUTEST_WARNINGFLAGS += -Wno-shadow
CPPUTEST_WARNINGFLAGS += -Wno-covered-switch-default
CPPUTEST_CFLAGS += -std=c99
CPPUTEST_CFLAGS += -Wextra
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wstrict-prototypes

SRC_DIRS = \
src/*\
src/MyOS/Acme\
Expand All @@ -47,5 +34,6 @@ INCLUDE_DIRS =\
mocks/IO \
mocks


CPPUTEST_USE_EXTENSIONS = Y
include ../CppUTestCompileFlags.mk
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
11 changes: 1 addition & 10 deletions code-t2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ TEST_TARGET = \
PROJECT_HOME_DIR = .
CPP_PLATFORM = Gcc

CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wswitch-enum
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
CPPUTEST_CFLAGS += -std=c99
CPPUTEST_CFLAGS += -Wextra
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wstrict-prototypes

SRC_DIRS = \
src/*\

Expand All @@ -41,4 +31,5 @@ INCLUDE_DIRS =\
include/devices\
include/MyOS\

include ../CppUTestCompileFlags.mk
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
13 changes: 2 additions & 11 deletions code-t3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ TEST_TARGET = \
PROJECT_HOME_DIR = .
CPP_PLATFORM = Gcc

CPPUTEST_USE_EXTENSIONS = Y
CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Wswitch-enum
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
CPPUTEST_CFLAGS += -std=c99
CPPUTEST_CFLAGS += -Wextra
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wstrict-prototypes

SRC_DIRS = \
src/*\

Expand All @@ -39,4 +28,6 @@ INCLUDE_DIRS =\
include/*\
mocks

CPPUTEST_USE_EXTENSIONS = Y
include ../CppUTestCompileFlags.mk
include $(CPPUTEST_HOME)/build/MakefileWorker.mk
18 changes: 3 additions & 15 deletions code/MakefileCppUTest.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,9 @@ INCLUDE_DIRS =\

MOCKS_SRC_DIRS = \
mocks\

CPPUTEST_WARNINGFLAGS += -Wall
CPPUTEST_WARNINGFLAGS += -Wswitch-default
CPPUTEST_WARNINGFLAGS += -Werror
CPPUTEST_WARNINGFLAGS += -Wno-format-nonliteral
CPPUTEST_WARNINGFLAGS += -Wno-sign-conversion
CPPUTEST_WARNINGFLAGS += -Wno-pedantic
CPPUTEST_WARNINGFLAGS += -Wno-shadow
CPPUTEST_WARNINGFLAGS += -Wno-missing-field-initializers
CPPUTEST_WARNINGFLAGS += -Wno-unused-parameter
#CPPUTEST_CFLAGS = -std=c89
CPPUTEST_CFLAGS += -Wall
CPPUTEST_CFLAGS += -Wstrict-prototypes
CPPUTEST_CFLAGS += -pedantic
CPPUTEST_CFLAGS += -Wno-missing-prototypes

include ../CppUTestCompileFlags.mk

LD_LIBRARIES = -lpthread


Expand Down

0 comments on commit 6fd4a25

Please sign in to comment.