Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3137c5

Browse files
pm-twicelava
authored andcommitted
Fix for imshow multiple definition error lava#48
When multiple files include matplotlibcpp.h and another file load these files in the same time, compile error of multiple definition in imshow occurs. This fix add inline modifier to imshow().
1 parent f4ad842 commit d3137c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

matplotlibcpp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ bool hist(const std::vector<Numeric>& y, long bins=10,std::string color="b",
579579

580580
#ifndef WITHOUT_NUMPY
581581
namespace internal {
582-
void imshow(void *ptr, const NPY_TYPES type, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords)
582+
inline void imshow(void *ptr, const NPY_TYPES type, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords)
583583
{
584584
assert(type == NPY_UINT8 || type == NPY_FLOAT);
585585
assert(colors == 1 || colors == 3 || colors == 4);
@@ -607,12 +607,12 @@ bool hist(const std::vector<Numeric>& y, long bins=10,std::string color="b",
607607
}
608608
}
609609

610-
void imshow(const unsigned char *ptr, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords = {})
610+
inline void imshow(const unsigned char *ptr, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords = {})
611611
{
612612
internal::imshow((void *) ptr, NPY_UINT8, rows, columns, colors, keywords);
613613
}
614614

615-
void imshow(const float *ptr, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords = {})
615+
inline void imshow(const float *ptr, const int rows, const int columns, const int colors, const std::map<std::string, std::string> &keywords = {})
616616
{
617617
internal::imshow((void *) ptr, NPY_FLOAT, rows, columns, colors, keywords);
618618
}

0 commit comments

Comments
 (0)