-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add example violating one-definition-rule (odr)
ref: #41
- Loading branch information
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PROJECT = odr | ||
|
||
CXX = g++ | ||
LD = g++ | ||
RM = rm -f | ||
|
||
|
||
SRC_DIRS = . | ||
INCLUDE = -I ../../include | ||
|
||
SRCS = $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS))) | ||
OBJS = $(SRCS:.cpp=.o) | ||
DEPENDS = $(OBJS:.o=.d) | ||
|
||
EXE = $(PROJECT) | ||
MAP = $(PROJECT).map | ||
|
||
|
||
#------------------------------------------------------------------------------ | ||
# flags | ||
# | ||
|
||
# commmon flags propagated to CFLAGS, CXXFLAGS, ASFLAGS (not LDFLAGS) | ||
FLAGS += $(INCLUDE) | ||
FLAGS += -MMD | ||
|
||
CXXFLAGS = $(FLAGS) | ||
CXXFLAGS += -std=c++11 | ||
CXXFLAGS += -fno-exceptions | ||
CXXFLAGS += -fno-rtti | ||
|
||
CXXFLAGS += -Wall -Wextra | ||
CXXFLAGS += -Wctor-dtor-privacy | ||
CXXFLAGS += -Wcast-align -Wpointer-arith -Wredundant-decls | ||
CXXFLAGS += -Wshadow -Wcast-qual -Wcast-align -pedantic | ||
|
||
LDFLAGS += -fno-exceptions | ||
LDFLAGS += -fno-rtti | ||
|
||
|
||
# Enable link-time optimizer | ||
#CXXFLAGS += -flto | ||
#LDFLAGS += -flto | ||
|
||
|
||
.PHONY: all clean | ||
|
||
all: $(EXE) | ||
|
||
$(EXE): $(OBJS) | ||
$(LD) $(OBJS) $(LDFLAGS) -o $(EXE) | ||
|
||
%.o: %.cpp | ||
$(CXX) -c $(CXXFLAGS) -o $@ $< | ||
|
||
clean: | ||
$(RM) *.o | ||
$(RM) *.d | ||
$(RM) $(EXE) | ||
|
||
|
||
-include $(DEPENDS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
extern void init_one(); | ||
extern void init_two(); | ||
|
||
int main() | ||
{ | ||
init_one(); | ||
init_two(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
|
||
#include "tinyfsm.hpp" | ||
|
||
struct One : tinyfsm::Fsm<One> | ||
{ | ||
virtual void entry() {} | ||
}; | ||
|
||
struct FirstState : One | ||
{ | ||
void entry() override { std::cout << "entering Firstate of One" << std::endl; } | ||
}; | ||
|
||
FSM_INITIAL_STATE(One, FirstState); | ||
|
||
|
||
void init_one() | ||
{ | ||
One::start(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <iostream> | ||
|
||
#include "tinyfsm.hpp" | ||
|
||
struct Two : tinyfsm::Fsm<Two> | ||
{ | ||
virtual void entry() {} | ||
}; | ||
|
||
struct FirstState : Two | ||
{ | ||
void entry() override { std::cout << "entering Firstate of Two" << std::endl; } | ||
}; | ||
|
||
FSM_INITIAL_STATE(Two, FirstState); | ||
|
||
|
||
void init_two() | ||
{ | ||
Two::start(); | ||
} |