Skip to content

Commit

Permalink
Partially revert changes of list data types (fix compiler warnings)
Browse files Browse the repository at this point in the history
Changing from class to struct causes clang compiler warnings like this one:

In file included from ../../../src/api/baseapi.cpp:63:
../../../include/tesseract/osdetect.h:29:1: warning: class 'BLOB_CHOICE_LIST' was previously declared as a struct; this is valid, but may result in linker errors under the Microsoft C++ ABI [-Wmismatched-tags]
class BLOB_CHOICE_LIST;
^
../../../src/ccstruct/ratngs.h:228:1: note: previous use is here
ELISTIZEH(BLOB_CHOICE)
^
../../../src/ccutil/elst.h:804:10: note: expanded from macro 'ELISTIZEH'
  struct CLASSNAME##_LIST : X_LIST<ELIST, ELIST_ITERATOR, CLASSNAME> { \
         ^
<scratch space>:458:1: note: expanded from here
BLOB_CHOICE_LIST
^
../../../include/tesseract/osdetect.h:29:1: note: did you mean struct here?
class BLOB_CHOICE_LIST;
^~~~~

As it is not possible to change the API header tesseract/osdetect.h,
some of the changes from class to struct had to be reverted.

Fixes: 968d653 ("Shorten macros")
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Feb 9, 2022
1 parent acd6f6c commit ebf367e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ccstruct/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace tesseract {

struct BLOB_CHOICE_LIST;
class BLOB_CHOICE_LIST;
class UNICHARSET;

#define NOT_CLASSIFIED static_cast<BLOB_CHOICE_LIST *>(nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/ccutil/clst.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class X_CLIST : public CLIST {
};

#define CLISTIZEH(CLASSNAME) \
struct CLASSNAME##_CLIST : X_CLIST<CLASSNAME> { \
class CLASSNAME##_CLIST : public X_CLIST<CLASSNAME> { \
using X_CLIST<CLASSNAME>::X_CLIST; \
}; \
struct CLASSNAME##_C_IT : X_ITER<CLIST_ITERATOR, CLASSNAME> { \
Expand Down
12 changes: 6 additions & 6 deletions src/ccutil/elst.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,12 +800,12 @@ inline void ELIST_ITERATOR::add_to_end( // element to add
}
}

#define ELISTIZEH(CLASSNAME) \
struct CLASSNAME##_LIST : X_LIST<ELIST, ELIST_ITERATOR, CLASSNAME> { \
using X_LIST<ELIST, ELIST_ITERATOR, CLASSNAME>::X_LIST; \
}; \
struct CLASSNAME##_IT : X_ITER<ELIST_ITERATOR, CLASSNAME> { \
using X_ITER<ELIST_ITERATOR, CLASSNAME>::X_ITER; \
#define ELISTIZEH(CLASSNAME) \
class CLASSNAME##_LIST : public X_LIST<ELIST, ELIST_ITERATOR, CLASSNAME> { \
using X_LIST<ELIST, ELIST_ITERATOR, CLASSNAME>::X_LIST; \
}; \
class CLASSNAME##_IT : public X_ITER<ELIST_ITERATOR, CLASSNAME> { \
using X_ITER<ELIST_ITERATOR, CLASSNAME>::X_ITER; \
};

} // namespace tesseract
Expand Down
18 changes: 9 additions & 9 deletions src/ccutil/elst2.h
Original file line number Diff line number Diff line change
Expand Up @@ -819,15 +819,15 @@ inline void ELIST2_ITERATOR::add_to_end( // element to add
}
}

#define ELIST2IZEH(CLASSNAME) \
struct CLASSNAME##_LIST : X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME> { \
using X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME>::X_LIST; \
}; \
struct CLASSNAME##_IT : X_ITER<ELIST2_ITERATOR, CLASSNAME> { \
using X_ITER<ELIST2_ITERATOR, CLASSNAME>::X_ITER; \
CLASSNAME *backward() { \
return reinterpret_cast<CLASSNAME *>(ELIST2_ITERATOR::backward()); \
} \
#define ELIST2IZEH(CLASSNAME) \
class CLASSNAME##_LIST : public X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME> { \
using X_LIST<ELIST2, ELIST2_ITERATOR, CLASSNAME>::X_LIST; \
}; \
struct CLASSNAME##_IT : X_ITER<ELIST2_ITERATOR, CLASSNAME> { \
using X_ITER<ELIST2_ITERATOR, CLASSNAME>::X_ITER; \
CLASSNAME *backward() { \
return reinterpret_cast<CLASSNAME *>(ELIST2_ITERATOR::backward()); \
} \
};

} // namespace tesseract
Expand Down

0 comments on commit ebf367e

Please sign in to comment.