Skip to content

Commit

Permalink
Remove BOOL8, TRUE, FALSE from host.h
Browse files Browse the repository at this point in the history
Remove unneeded include statements for host.h, add required ones and
update the comments for the remaining include statements.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Mar 31, 2019
1 parent be96b7b commit 802f42e
Show file tree
Hide file tree
Showing 29 changed files with 23 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/ccstruct/blobbox.h
Expand Up @@ -25,6 +25,7 @@
#include "elst.h" // for ELIST_ITERATOR, ELISTIZEH, ELIST_LINK
#include "elst2.h" // for ELIST2_ITERATOR, ELIST2IZEH, ELIST2_LINK
#include "errcode.h" // for ASSERT_HOST
#include "host.h" // for PRId32
#include "ocrblock.h" // for BLOCK
#include "params.h" // for DoubleParam, double_VAR_H
#include "pdblock.h" // for PDBLK
Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/boxword.cpp
Expand Up @@ -2,7 +2,6 @@
// File: boxword.cpp
// Description: Class to represent the bounding boxes of the output.
// Author: Ray Smith
// Created: Tue May 25 14:18:14 PDT 2010
//
// (C) Copyright 2010, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,6 +18,7 @@

#include "blobs.h"
#include "boxword.h"
#include "host.h" // for NearlyEqual
#include "normalis.h"
#include "ocrblock.h"
#include "pageres.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ccstruct/imagedata.cpp
Expand Up @@ -3,7 +3,6 @@
// Description: Class to hold information about a single multi-page tiff
// training file and its corresponding boxes or text file.
// Author: Ray Smith
// Created: Tue May 28 08:56:06 PST 2013
//
// (C) Copyright 2013, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,6 +33,7 @@
#include "boxread.h" // for ReadMemBoxes
#include "callcpp.h" // for window_wait
#include "helpers.h" // for IntCastRounded, TRand, ClipToRange, Modulo
#include "host.h" // for PRId64
#include "rect.h" // for TBOX
#include "scrollview.h" // for ScrollView, ScrollView::CYAN, ScrollView::NONE
#include "serialis.h" // for TFile
Expand Down
1 change: 1 addition & 0 deletions src/ccstruct/polyblk.cpp
Expand Up @@ -21,6 +21,7 @@
#include <cstdio>
#include <memory> // std::unique_ptr
#include "elst.h"
#include "host.h" // for PRId32

// Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H
Expand Down
2 changes: 0 additions & 2 deletions src/ccstruct/rejctmap.cpp
Expand Up @@ -2,7 +2,6 @@
* File: rejctmap.cpp (Formerly rejmap.c)
* Description: REJ and REJMAP class functions.
* Author: Phil Cheatle
* Created: Thu Jun 9 13:46:38 BST 1994
*
* (C) Copyright 1994, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,7 +16,6 @@
*
**********************************************************************/

#include "host.h"
#include "rejctmap.h"
#include "params.h"

Expand Down
2 changes: 0 additions & 2 deletions src/ccstruct/statistc.h
Expand Up @@ -2,7 +2,6 @@
* File: statistc.h (Formerly stats.h)
* Description: Class description for STATS class.
* Author: Ray Smith
* Created: Mon Feb 04 16:19:07 GMT 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,7 +20,6 @@
#define TESSERACT_CCSTRUCT_STATISTC_H_

#include <cstdio>
#include "host.h"
#include "kdpair.h"
#include "scrollview.h"

Expand Down
5 changes: 1 addition & 4 deletions src/ccutil/bitvector.h
@@ -1,10 +1,7 @@
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: rays@google.com (Ray Smith)
///////////////////////////////////////////////////////////////////////
// File: bitvector.h
// Description: Class replacement for BITVECTOR.
// Author: Ray Smith
// Created: Mon Jan 10 17:44:01 PST 2011
//
// (C) Copyright 2011, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,8 +20,8 @@
#define TESSERACT_CCUTIL_BITVECTOR_H_

#include <cassert>
#include <cstdint> // for uint8_t
#include <cstdio>
#include "host.h"

namespace tesseract {

Expand Down
2 changes: 1 addition & 1 deletion src/ccutil/errcode.h
Expand Up @@ -19,7 +19,7 @@
#ifndef ERRCODE_H
#define ERRCODE_H

#include "host.h"
#include "platform.h" // for TESS_API

/*Control parameters for error()*/
enum TessErrorLogCode {
Expand Down
8 changes: 3 additions & 5 deletions src/ccutil/globaloc.h
Expand Up @@ -2,7 +2,6 @@
* File: globaloc.h (Formerly error.h)
* Description: Header file for generic error handler class
* Author: Ray Smith
* Created: Tue May 1 16:23:36 BST 1990
*
* (C) Copyright 1990, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,10 +16,8 @@
*
**********************************************************************/

#ifndef GLOBALOC_H
#define GLOBALOC_H

#include "host.h"
#ifndef GLOBALOC_H
#define GLOBALOC_H

// Saves a clone of the given pix, and notes its resolution in thread-specific
// data, so that the image can be written prior to a crash.
Expand All @@ -36,4 +33,5 @@ void set_global_loc_code(int loc_code);
void set_global_subloc_code(int loc_code);

void set_global_subsubloc_code(int loc_code);

#endif
12 changes: 0 additions & 12 deletions src/ccutil/host.h
Expand Up @@ -30,9 +30,6 @@
#include <cinttypes> // PRId32, ...
#include <cstdint> // int32_t, ...

// definitions of portable data types (numbers and characters)
using BOOL8 = unsigned char;

#if defined(_WIN32)

/* MinGW defines the standard PRI... macros, but MSVS doesn't. */
Expand All @@ -47,15 +44,6 @@ using BOOL8 = unsigned char;

#endif /* _WIN32 */

// Defines
#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

// Return true if x is within tolerance of y
template<class T> bool NearlyEqual(T x, T y, T tolerance) {
T diff = x - y;
Expand Down
5 changes: 2 additions & 3 deletions src/ccutil/params.cpp
Expand Up @@ -2,7 +2,6 @@
* File: params.cpp
* Description: Initialization and setting of Tesseract parameters.
* Author: Ray Smith
* Created: Fri Feb 22 16:22:34 GMT 1991
*
* (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -153,7 +152,7 @@ bool ParamUtils::GetParamAsString(const char *name,
auto *bp = FindParam<BoolParam>(name, GlobalParams()->bool_params,
member_params->bool_params);
if (bp != nullptr) {
*value = BOOL8(*bp) ? "1": "0";
*value = bool(*bp) ? "1": "0";
return true;
}
// Look for the parameter among double parameters.
Expand All @@ -179,7 +178,7 @@ void ParamUtils::PrintParams(FILE *fp, const ParamsVectors *member_params) {
}
for (i = 0; i < vec->bool_params.size(); ++i) {
fprintf(fp, "%s\t%d\t%s\n", vec->bool_params[i]->name_str(),
(BOOL8)(*vec->bool_params[i]), vec->bool_params[i]->info_str());
bool(*vec->bool_params[i]), vec->bool_params[i]->info_str());
}
for (int i = 0; i < vec->string_params.size(); ++i) {
fprintf(fp, "%s\t%s\t%s\n", vec->string_params[i]->name_str(),
Expand Down
11 changes: 5 additions & 6 deletions src/ccutil/params.h
Expand Up @@ -22,7 +22,6 @@
#include <cstdio>

#include "genericvector.h"
#include "host.h" // for BOOL8
#include "strngs.h"

namespace tesseract {
Expand Down Expand Up @@ -180,9 +179,9 @@ class BoolParam : public Param {
vec->bool_params.push_back(this);
}
~BoolParam() { ParamUtils::RemoveParam<BoolParam>(this, params_vec_); }
operator BOOL8() const { return value_; }
void operator=(BOOL8 value) { value_ = value; }
void set_value(BOOL8 value) { value_ = value; }
operator bool() const { return value_; }
void operator=(bool value) { value_ = value; }
void set_value(bool value) { value_ = value; }
void ResetToDefault() { value_ = default_; }
void ResetFrom(const ParamsVectors* vec) {
for (int i = 0; i < vec->bool_params.size(); ++i) {
Expand All @@ -196,8 +195,8 @@ class BoolParam : public Param {
}

private:
BOOL8 value_;
BOOL8 default_;
bool value_;
bool default_;
// Pointer to the vector that contains this param (not owned by this class).
GenericVector<BoolParam*>* params_vec_;
};
Expand Down
2 changes: 0 additions & 2 deletions src/ccutil/unicharmap.cpp
Expand Up @@ -2,7 +2,6 @@
// File: unicharmap.cpp
// Description: Unicode character/ligature to integer id class.
// Author: Thomas Kielbus
// Created: Wed Jun 28 17:05:01 PDT 2006
//
// (C) Copyright 2006, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +18,6 @@

#include <cassert>
#include "unichar.h"
#include "host.h"
#include "unicharmap.h"

UNICHARMAP::UNICHARMAP() :
Expand Down
2 changes: 0 additions & 2 deletions src/ccutil/unicodes.cpp
Expand Up @@ -2,7 +2,6 @@
* File: unicodes.cpp
* Description: Unicode related machinery
* Author: David Eger
* Created: Wed Jun 15 16:37:50 PST 2011
*
* (C) Copyright 2011, Google, Inc.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +17,6 @@
**********************************************************************/

#include "unicodes.h"
#include "host.h" // for nullptr

namespace tesseract {

Expand Down
1 change: 0 additions & 1 deletion src/classify/clusttool.h
Expand Up @@ -21,7 +21,6 @@
//--------------------------Include Files---------------------------------------
#include <cstdio>
#include "cluster.h"
#include "host.h"
#include "serialis.h"

/*-------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/classify/fpoint.h
Expand Up @@ -24,7 +24,6 @@
----------------------------------------------------------------------------**/
#include <cmath>
#include <cstdio>
#include "host.h"

/* define data structure to hold 2D points or vectors using floating point */
typedef struct {
Expand Down
3 changes: 2 additions & 1 deletion src/classify/kdtree.h
Expand Up @@ -14,13 +14,13 @@
** See the License for the specific language governing permissions and
** limitations under the License.
*****************************************************************************/

#ifndef KDTREE_H
#define KDTREE_H

/*-----------------------------------------------------------------------------
Include Files and Type Defines
-----------------------------------------------------------------------------*/
#include "host.h"
#include "ocrfeatures.h"

typedef void (*void_proc)(...);
Expand Down Expand Up @@ -92,4 +92,5 @@ void Walk(KDTREE *tree, void_proc action, void *context,
void InsertNodes(KDTREE *tree, KDNODE *nodes);

void FreeSubTree(KDNODE *SubTree);

#endif
4 changes: 2 additions & 2 deletions src/cutil/bitvec.h
Expand Up @@ -2,7 +2,6 @@
** Filename: bitvec.h
** Purpose: Routines for manipulating bit vectors
** Author: Dan Johnson
** History: Wed Mar 7 17:52:45 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,10 +14,11 @@
** See the License for the specific language governing permissions and
** limitations under the License.
******************************************************************************/

#ifndef BITVEC_H
#define BITVEC_H

#include "host.h"
#include <cstdint> // for uint32_t

/*-----------------------------------------------------------------------------
Include Files and Type Defines
Expand Down
1 change: 0 additions & 1 deletion src/cutil/callcpp.h
Expand Up @@ -20,7 +20,6 @@
#ifndef CALLCPP_H
#define CALLCPP_H

#include "host.h"
#include "params.h"
#include "unichar.h"

Expand Down
2 changes: 2 additions & 0 deletions src/dict/dawg.h
Expand Up @@ -26,8 +26,10 @@
I n c l u d e s
----------------------------------------------------------------------*/

#include <cinttypes> // for PRId64
#include <memory>
#include "elst.h"
#include "host.h" // for PRId64
#include "params.h"
#include "ratngs.h"
#include "tesscallback.h"
Expand Down
1 change: 0 additions & 1 deletion src/dict/dict.h
Expand Up @@ -22,7 +22,6 @@
#include "ambigs.h"
#include "dawg.h"
#include "dawg_cache.h"
#include "host.h"
#include "ratngs.h"
#include "stopper.h"
#include "trie.h"
Expand Down
2 changes: 0 additions & 2 deletions src/dict/matchdefs.h
Expand Up @@ -2,7 +2,6 @@
** Filename: matchdefs.h
** Purpose: Generic interface definitions for feature matchers.
** Author: Dan Johnson
** History: Fri Jan 19 09:21:25 1990, DSJ, Created.
**
** (c) Copyright Hewlett-Packard Company, 1988.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,7 +21,6 @@
/**----------------------------------------------------------------------------
Include Files and Type Defines
----------------------------------------------------------------------------**/
#include "host.h"
#include <cstdio>
#include "unichar.h"

Expand Down
1 change: 0 additions & 1 deletion src/lstm/ctc.cpp
Expand Up @@ -22,7 +22,6 @@
#include <memory>

#include "genericvector.h"
#include "host.h"
#include "matrix.h"
#include "networkio.h"

Expand Down
2 changes: 0 additions & 2 deletions src/textord/imagefind.h
Expand Up @@ -3,7 +3,6 @@
// Description: Class to find image and drawing regions in an image
// and create a corresponding list of empty blobs.
// Author: Ray Smith
// Created: Fri Aug 01 10:50:01 PDT 2008
//
// (C) Copyright 2008, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,7 +21,6 @@
#define TESSERACT_TEXTORD_IMAGEFIND_H_

#include "debugpixa.h"
#include "host.h"

struct Boxa;
struct Pix;
Expand Down
2 changes: 0 additions & 2 deletions src/training/dawg2wordlist.cpp
Expand Up @@ -2,7 +2,6 @@
// File: dawg2wordlist.cpp
// Description: Program to create a word list from a DAWG and unicharset.
// Author: David Eger
// Created: Thu 22 Dec 2011
//
// (C) Copyright 2011, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +18,6 @@

#include "commontraining.h" // CheckSharedLibraryVersion
#include "dawg.h"
#include "host.h"
#include "serialis.h"
#include "tesscallback.h"
#include "trie.h"
Expand Down

5 comments on commit 802f42e

@nguyenq
Copy link
Contributor

@nguyenq nguyenq commented on 802f42e Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit failed my Windows build:

Severity	Code	Description	Project	File	Line	Suppression State
Error	C2143	syntax error: missing ',' before '*'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	85	
Error	C2065	'M_PI': undeclared identifier	libtesseract410	c:\projects\github\tesseract-ocr\src\classify\fpoint.cpp	45	
Error	C4430	missing type specifier - int assumed. Note: C++ does not support default-int	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	85	
Error	C3646	'ComposeRGB': unknown override specifier	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	89	
Error	C2065	'uint32_t': undeclared identifier	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	89	
Error	C2146	syntax error: missing ')' before identifier 'r'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	89	
Error	C2238	unexpected token(s) preceding ';'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	89	
Error	C3646	'ClipToByte': unknown override specifier	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	92	
Error	C2062	type 'double' unexpected	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	92	
Error	C2238	unexpected token(s) preceding ';'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	92	
Error	C2061	syntax error: identifier 'uint8_t'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.h	107	
Error	C2511	'double tesseract::ImageFind::ColorDistanceFromLine(const uint8_t *,const uint8_t *,const uint8_t *)': overloaded member function not found in 'tesseract::ImageFind'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.cpp	358	
Error	C2039	'ComposeRGB': is not a member of 'tesseract::ImageFind'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.cpp	390	
Error	C2039	'ClipToByte': is not a member of 'tesseract::ImageFind'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.cpp	397	
Error	C2511	'void tesseract::ImageFind::ComputeRectangleColors(const TBOX &,Pix *,int,Pix *,Pix *,Pix *,uint8_t *,uint8_t *)': overloaded member function not found in 'tesseract::ImageFind'	libtesseract410	c:\projects\github\tesseract-ocr\src\textord\imagefind.cpp	418	

@zdenop
Copy link
Contributor

@zdenop zdenop commented on 802f42e Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you try to build tesseract?

@stweil
Copy link
Contributor Author

@stweil stweil commented on 802f42e Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nguyenq, commit c150b98 fixed the include statements for fpoint.cpp. Please use the latest code from GitHub.

@nguyenq
Copy link
Contributor

@nguyenq nguyenq commented on 802f42e Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zdenop I've been using the VS project from https://github.com/charlesw to build tesseract binaries.

@stweil With the latest code, I got many errors:

1>  c:\projects\github\tesseract-ocr\src\ccstruct\rect.h(226): error C2589: '(': illegal token on right side of '::'
1>  c:\projects\github\tesseract-ocr\src\ccstruct\rect.h(226): error C2062: type 'unknown-type' unexpected
1>  c:\projects\github\tesseract-ocr\src\ccstruct\rect.h(226): error C2059: syntax error: ')'

A brief web search produced the fix. I only needed to define NOMINMAX constant in the Preprocessor Definition of the VS project. All is well now.

@stweil
Copy link
Contributor Author

@stweil stweil commented on 802f42e Apr 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tesseract defines NOMINMAX in CMakeLists.txt, so if you build the VS project using CMake, you get that define. I suggest to report that problem to @charlesw.

Please sign in to comment.