Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
34b0a2e1
Commit
34b0a2e1
authored
7 years ago
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a link time check that you aren't mixing headers from one version of dlib
with binaries from a different dlib version.
parent
e8117679
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
CMakeLists.txt
dlib/CMakeLists.txt
+7
-0
config.h.in
dlib/config.h.in
+5
-0
test_for_odr_violations.cpp
dlib/test_for_odr_violations.cpp
+9
-0
test_for_odr_violations.h
dlib/test_for_odr_violations.h
+9
-4
No files found.
dlib/CMakeLists.txt
View file @
34b0a2e1
...
@@ -744,6 +744,13 @@ if (NOT TARGET dlib)
...
@@ -744,6 +744,13 @@ if (NOT TARGET dlib)
# the code in dlib/threads_kernel_shared.cpp to emit a linker error for users who
# the code in dlib/threads_kernel_shared.cpp to emit a linker error for users who
# don't use the configured config.h file generated by cmake.
# don't use the configured config.h file generated by cmake.
target_compile_options
(
dlib PRIVATE -DDLIB__CMAKE_GENERATED_A_CONFIG_H_FILE
)
target_compile_options
(
dlib PRIVATE -DDLIB__CMAKE_GENERATED_A_CONFIG_H_FILE
)
# Do this so that dlib/config.h can record the version of dlib it's configured with
# and ultimately issue a linker error to people who try to use a binary dlib that is
# the wrong version.
set
(
DLIB_CHECK_FOR_VERSION_MISSMATCH
DLIB_VERSION_CHECK_
${
CPACK_PACKAGE_VERSION_MAJOR
}
_
${
CPACK_PACKAGE_VERSION_MINOR
}
_
${
CPACK_PACKAGE_VERSION_PATCH
}
)
target_compile_options
(
dlib PRIVATE
"-DDLIB_CHECK_FOR_VERSION_MISSMATCH=
${
DLIB_CHECK_FOR_VERSION_MISSMATCH
}
"
)
endif
()
endif
()
...
...
This diff is collapsed.
Click to expand it.
dlib/config.h.in
View file @
34b0a2e1
...
@@ -27,3 +27,8 @@
...
@@ -27,3 +27,8 @@
#cmakedefine DLIB_USE_LAPACK
#cmakedefine DLIB_USE_LAPACK
#cmakedefine DLIB_USE_CUDA
#cmakedefine DLIB_USE_CUDA
#cmakedefine DLIB_USE_MKL_FFT
#cmakedefine DLIB_USE_MKL_FFT
// This variable allows dlib/test_for_odr_violations.h to catch people who mistakenly use
// headers from one version of dlib with a compiled dlib binary from a different dlib version.
#cmakedefine DLIB_CHECK_FOR_VERSION_MISSMATCH @DLIB_CHECK_FOR_VERSION_MISSMATCH@
This diff is collapsed.
Click to expand it.
dlib/test_for_odr_violations.cpp
View file @
34b0a2e1
...
@@ -31,6 +31,15 @@ extern "C"
...
@@ -31,6 +31,15 @@ extern "C"
#if defined(DLIB_NOT_CONFIGURED) && !defined(DLIB__CMAKE_GENERATED_A_CONFIG_H_FILE)
#if defined(DLIB_NOT_CONFIGURED) && !defined(DLIB__CMAKE_GENERATED_A_CONFIG_H_FILE)
int
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
;
int
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
;
#endif
#endif
#ifdef DLIB_CHECK_FOR_VERSION_MISSMATCH
int
DLIB_CHECK_FOR_VERSION_MISSMATCH
;
#endif
}
}
...
...
This diff is collapsed.
Click to expand it.
dlib/test_for_odr_violations.h
View file @
34b0a2e1
...
@@ -41,15 +41,20 @@ extern "C"
...
@@ -41,15 +41,20 @@ extern "C"
#if defined(DLIB_NOT_CONFIGURED) && !defined(DLIB__CMAKE_GENERATED_A_CONFIG_H_FILE)
#if defined(DLIB_NOT_CONFIGURED) && !defined(DLIB__CMAKE_GENERATED_A_CONFIG_H_FILE)
extern
int
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
;
extern
int
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
;
inline
int
dlib_check_consistent_config_h_usage
()
{
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
=
0
;
return
0
;
}
inline
int
dlib_check_consistent_config_h_usage
()
{
USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2
=
0
;
return
0
;
}
#else
inline
int
dlib_check_consistent_config_h_usage
()
{
return
0
;
}
#endif
const
int
DLIB_NO_WARN_UNUSED
dlib_check_not_configured_helper_variable
=
dlib_check_consistent_config_h_usage
();
const
int
DLIB_NO_WARN_UNUSED
dlib_check_not_configured_helper_variable
=
dlib_check_consistent_config_h_usage
();
#endif
}
// Cause the user to get a linker error if they try to use header files from one version of
// dlib with the compiled binary from a different version of dlib.
#ifdef DLIB_CHECK_FOR_VERSION_MISSMATCH
extern
int
DLIB_CHECK_FOR_VERSION_MISSMATCH
;
inline
int
dlib_check_for_dlib_version_missmatch
()
{
DLIB_CHECK_FOR_VERSION_MISSMATCH
=
0
;
return
0
;
}
const
int
DLIB_NO_WARN_UNUSED
dlib_check_for_version_missmatch
=
dlib_check_for_dlib_version_missmatch
();
#endif
}
#endif // DLIB_TEST_FOR_ODR_VIOLATIONS_H_
#endif // DLIB_TEST_FOR_ODR_VIOLATIONS_H_
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment