tesseract v5.3.3.20231005
host.h
Go to the documentation of this file.
1/******************************************************************************
2 ** Filename: host.h
3 ** Purpose: This is the system independent typedefs and defines
4 ** Author: MN, JG, MD
5 **
6 ** (c) Copyright Hewlett-Packard Company, 1988-1996.
7 ** Licensed under the Apache License, Version 2.0 (the "License");
8 ** you may not use this file except in compliance with the License.
9 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18#ifndef TESSERACT_CCUTIL_HOST_H_
19#define TESSERACT_CCUTIL_HOST_H_
20
21#include <tesseract/export.h>
22
23#include <climits>
24#include <limits>
25
26/* _WIN32 */
27#ifdef _WIN32
28# ifndef NOMINMAX
29# define NOMINMAX
30# endif /* NOMINMAX */
31# ifndef WIN32_LEAN_AND_MEAN
32# define WIN32_LEAN_AND_MEAN
33# endif
34# include <windows.h>
35# undef min
36# undef max
37#endif // _WIN32
38
39#ifndef _WIN32
40# ifndef PATH_MAX
41# define MAX_PATH 4096
42# else
43# define MAX_PATH PATH_MAX
44# endif
45#endif
46
47namespace tesseract {
48
49// Return true if x is within tolerance of y
50template <class T>
51bool NearlyEqual(T x, T y, T tolerance) {
52 T diff = x - y;
53 return diff <= tolerance && -diff <= tolerance;
54}
55
56} // namespace tesseract
57
58#endif // TESSERACT_CCUTIL_HOST_H_
const double y
bool NearlyEqual(T x, T y, T tolerance)
Definition: host.h:51