aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <taywee@gmx.com>2017-11-26 09:41:51 -0700
committerGitHub <noreply@github.com>2017-11-26 09:41:51 -0700
commit8c32aefd61e259a4a8dde7eee1252accd4c63372 (patch)
treec15d9be9c6a252cbb14b81a653582358e1e810e1
parentMerge pull request #44 from pavel-belikov/better-value-parsing (diff)
parenttrigger travis ci (diff)
downloadargs.hxx-8c32aefd61e259a4a8dde7eee1252accd4c63372.tar.xz
Merge pull request #48 from pavel-belikov/fix-multiple-inclusion
Fix inclusion into multiple source files
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml2
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile2
-rw-r--r--args.hxx6
-rw-r--r--test/multiple_inclusion_1.cxx6
-rw-r--r--test/multiple_inclusion_2.cxx3
7 files changed, 20 insertions, 7 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/.travis.yml b/.travis.yml
index d4892fe..efba6f6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -145,6 +145,6 @@ before_install:
- pip install --user cpp-coveralls
after_success:
- - if [ "${COVERAGE}" = 1 ]; then coveralls --root .. -E ".*catch.*" -E ".*CMakeFiles.*" -E ".*gitlike.cxx.*" -E ".*test.cxx.*"; fi
+ - if [ "${COVERAGE}" = 1 ]; then coveralls --root .. -E ".*catch.*" -E ".*CMakeFiles.*" -E ".*gitlike.cxx.*" -E ".*test.*"; fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81864d7..322e8d1 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.cxx test/multiple_inclusion_2.cxx)
+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.cxx b/test/multiple_inclusion_1.cxx
new file mode 100644
index 0000000..b831d0a
--- /dev/null
+++ b/test/multiple_inclusion_1.cxx
@@ -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.cxx b/test/multiple_inclusion_2.cxx
new file mode 100644
index 0000000..cdcb020
--- /dev/null
+++ b/test/multiple_inclusion_2.cxx
@@ -0,0 +1,3 @@
+#include <args.hxx>
+
+int bar() { return 42; }