aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Belikov <pavel.fuchs.belikov@gmail.com>2017-11-23 18:56:27 +0300
committerPavel Belikov <pavel.fuchs.belikov@gmail.com>2017-11-23 18:56:27 +0300
commit922bc733353866719fbf5de29da23f423284d1dc (patch)
treeb67d3629772032e1983a45f3c8ad7af8f4856ea9
parentMerge pull request #44 from pavel-belikov/better-value-parsing (diff)
downloadargs.hxx-922bc733353866719fbf5de29da23f423284d1dc.tar.xz
fix inclusion into multiple source files
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile2
-rw-r--r--args.hxx6
-rw-r--r--test/multiple_inclusion_1.cpp6
-rw-r--r--test/multiple_inclusion_2.cpp3
6 files changed, 19 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index a2312f0..3b651bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,8 +29,6 @@
/userdoc.*
# test and temp files
-test*
-!test.cxx
*.pyc
*.swp
*.swo
@@ -38,6 +36,7 @@ test*
/ld
# Executable
+argstest
/build/
CMakeCache.txt
CMakeFiles
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81864d7..24d4a08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,5 +35,10 @@ else ()
target_compile_options(argstest PRIVATE -Wall -Wextra -Werror -pedantic -Wshadow -Wunused-parameter)
endif ()
+add_executable(argstest-multiple-inclusion test/multiple_inclusion_1.cpp test/multiple_inclusion_2.cpp)
+target_link_libraries(argstest-multiple-inclusion args)
+set_property(TARGET argstest-multiple-inclusion PROPERTY CXX_STANDARD 11)
+
enable_testing()
add_test(NAME "test" COMMAND argstest)
+add_test(NAME "test-multiple-inclusion" COMMAND argstest-multiple-inclusion)
diff --git a/Makefile b/Makefile
index 3a3c785..4c71e96 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ LDFLAGS += $(FLAGS)
SOURCES = test.cxx
OBJECTS = $(SOURCES:.cxx=.o)
DEPENDENCIES= $(SOURCES:.cxx=.d)
-EXECUTABLE = test
+EXECUTABLE = argstest
.PHONY: all clean pages runtests uninstall install installman
diff --git a/args.hxx b/args.hxx
index d31cdd6..03faade 100644
--- a/args.hxx
+++ b/args.hxx
@@ -2545,18 +2545,18 @@ namespace args
}
};
- Command::RaiiSubparser::RaiiSubparser(ArgumentParser &parser_, std::vector<std::string> args_)
+ inline Command::RaiiSubparser::RaiiSubparser(ArgumentParser &parser_, std::vector<std::string> args_)
: command(parser_.SelectedCommand()), parser(std::move(args_), parser_, command, parser_.helpParams), oldSubparser(command.subparser)
{
command.subparser = &parser;
}
- Command::RaiiSubparser::RaiiSubparser(const Command &command_, const HelpParams &params_): command(command_), parser(command, params_), oldSubparser(command.subparser)
+ inline Command::RaiiSubparser::RaiiSubparser(const Command &command_, const HelpParams &params_): command(command_), parser(command, params_), oldSubparser(command.subparser)
{
command.subparser = &parser;
}
- void Subparser::Parse()
+ inline void Subparser::Parse()
{
isParsed = true;
Reset();
diff --git a/test/multiple_inclusion_1.cpp b/test/multiple_inclusion_1.cpp
new file mode 100644
index 0000000..b831d0a
--- /dev/null
+++ b/test/multiple_inclusion_1.cpp
@@ -0,0 +1,6 @@
+#include <args.hxx>
+
+int foo() { return 42; }
+int bar();
+
+int main() { return foo() - bar(); }
diff --git a/test/multiple_inclusion_2.cpp b/test/multiple_inclusion_2.cpp
new file mode 100644
index 0000000..cdcb020
--- /dev/null
+++ b/test/multiple_inclusion_2.cpp
@@ -0,0 +1,3 @@
+#include <args.hxx>
+
+int bar() { return 42; }