Compilation errors in MSVC - c++

I'm usually a g++ user. And I loved it for it's simplicity, but I'm trying to test compiling a native executable because usually I create a static which is really heavy in size. But I'm having some errors.
One on this line : return in.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
warning C4003: not enough arguments for function-like macro invocation 'max'
file.cpp(95): error C2589: '(': illegal token on right side of '::'
file.cpp(95): error C2144: syntax error: 'unknown-type' should be preceded by ')'
file.cpp(95): error C2144: syntax error: 'unknown-type' should be preceded by ';'
file.cpp(95): error C2059: syntax error: ')'
and here
DWORD mxpath = MAX_PATH;
char ld[mxpath];
error C2131: expression did not evaluate to a constant
sas.cpp(76): note: failure was caused by a read of a variable outside its lifetime
sas.cpp(76): note: see usage of 'mxpath'
I don't understand what I'm doing wrong as this code works with g++ without any errors. I'm new to msvc and I wanted to see if it is better than compiling a g++ static.
Why are those errors coming?

Related

Got error message when run a simple tensorflow code after building Tensorflow c++ GPU version

Hey I'm using tensorflow c++. I built tensorflow with this. I built a GPU version. When I run the sample code, I got many errors.
I built tensorflow r2.5 and protobuf-3.9.2.
code:
#include <iostream>
#include <tensorflow/core/framework/graph.pb.h>
#include <tensorflow/core/public/session.h>
#include <tensorflow/core/public/version.h>
int main() {
std::cout << tf_git_version() << std::endl;
std::unique_ptr<tensorflow::Session> session(tensorflow::NewSession({}));
}
errors:
1>------ Build started: Project: TF_savedmodel, Configuration: Release x64 ------
1>Source.cpp
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\attr_value.pb.h(687,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\node_def.pb.h(97,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(300,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(332,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(587,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(590,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(621,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\function.pb.h(624,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\Eigen\src\Core\arch\Default\Half.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss
1>D:\tf_model\TF_savedmodel\include\Eigen\src\Core\arch\Default\BFloat16.h(1,1): warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss
1>D:\tf_model\TF_savedmodel\include\Eigen\src\Core\arch\Default\GenericPacketMathFunctions.h(678,1): warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss
1>D:\tf_model\TF_savedmodel\include\Eigen\src\Core\products\GeneralBlockPanelKernel.h(2065,1): warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tstring.h(350,40): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tstring.h(350): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tstring.h(350,56): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(383,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(382,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(383): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(383,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(383,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(384,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(384,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(384): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(384,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(384,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(385,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(385,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(385): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(385,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(385,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(386,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(386,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(386): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(386,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(386,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(387,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(387,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(387): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(387,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(387,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(388,1): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(388,1): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(388): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(388,1): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\default\logging.h(388,1): error C2143: syntax error: missing ';' before '{'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\error_codes.pb.h(80,92): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\error_codes.pb.h(80,92): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\error_codes.pb.h(80): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\error_codes.pb.h(80,92): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\error_codes.pb.h(81,92): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(106,67): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(106,67): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(106): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(106,67): error C2737: 'protected: static __int64 const tensorflow::TensorShapeRep::kMaxRep16': constexpr object must be initialized
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(106,67): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(107,67): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(107,67): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(107): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(107,67): error C2737: 'protected: static __int64 const tensorflow::TensorShapeRep::kMaxRep32': constexpr object must be initialized
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(107,67): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(108,72): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(108,72): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(108): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(108,72): error C2737: 'protected: static unsigned short const tensorflow::TensorShapeRep::kUnknownRep16': constexpr object must be initialized
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(108,72): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(109,72): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(109,72): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(109): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(109,72): error C2737: 'protected: static unsigned int const tensorflow::TensorShapeRep::kUnknownRep32': constexpr object must be initialized
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_shape.h(109,72): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\unsupported\Eigen\CXX11\src\Tensor\Tensor.h(76,1): warning C4554: '&': check operator precedence for possible error; use parentheses to clarify precedence
1>D:\tf_model\TF_savedmodel\include\unsupported\Eigen\CXX11\src\Tensor\TensorMap.h(43): message : see reference to class template instantiation 'Eigen::Tensor<T,1,1,int>' being compiled
1> with
1> [
1> T=float
1> ]
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\tensor_types.h(105): message : see reference to class template instantiation 'Eigen::TensorMap<Eigen::Tensor<T,1,1,int>,16,Eigen::MakePointer>' being compiled
1> with
1> [
1> T=float
1> ]
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(106,109): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(106,109): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(106): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(106,109): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(107,109): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(133,123): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(133,123): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(133): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(133,123): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(134,123): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(158,94): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(158,94): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(158): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(158,94): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\google\protobuf\type.pb.h(159,94): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tensor_coding.h(47,38): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tensor_coding.h(47): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\platform\tensor_coding.h(47,62): error C2059: syntax error: ')'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\framework\step_stats.pb.h(1180,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\cluster.pb.h(97,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\verifier_config.pb.h(72,131): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\verifier_config.pb.h(72,131): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\verifier_config.pb.h(72): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\verifier_config.pb.h(72,131): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\verifier_config.pb.h(73,131): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(94,131): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(94,131): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(94): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(94,131): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(95,131): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(120,137): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(120,137): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(120): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(120,137): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(121,137): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(146,153): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(146,153): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(146): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(146,153): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(147,153): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(176,139): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(176,139): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(176): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(176,139): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(177,139): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\rewriter_config.pb.h(543,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(156,133): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(156,133): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(156): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(156,133): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(157,133): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(183,151): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(183,151): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(183): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(183,151): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(184,151): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(211,173): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(211,173): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(211): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(211,173): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(212,173): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(238,131): warning C4003: not enough arguments for function-like macro invocation 'min'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(238,131): error C2589: '(': illegal token on right side of '::'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(238): error C2062: type 'unknown-type' unexpected
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(238,131): error C3805: 'type': unexpected token, expected either '}' or a ','
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(239,131): warning C4003: not enough arguments for function-like macro invocation 'max'
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(1951,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(3797,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(3800,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(3831,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\protobuf\config.pb.h(3834,1): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>D:\tf_model\TF_savedmodel\include\tensorflow\core\public\session_options.h(62,2): warning C4091: '__declspec(dllimport)': ignored on left of 'tensorflow::SessionOptions' when no variable is declared
1>Done building project "TF_savedmodel.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Some said this happened because of "Windows.h", but I didn't saw such a include command in these header files. Should I edit some of those files?
If someone could tell me how to solve that, it will be nice.
[solved] just add () to following files which using std::XXX::min/ max().

Adding new Dialog to legacy C++ app (VS2017) results in many errors. Why?

This is a legacy C++ app. It's been ported from VS 6.0, to VS2015, and now to VS2017. In 2017, I add a dialog via the menus/resource wizards. The act of this dialog causes all kinds of issues with ATL. (Error examples below...)
c:\program files (x86)\microsoft visual studio\2017\professional\vc\tools\msvc\14.14.26428\atlmfc\include\afxbutton.h(184): warning C4003: not enough actual parameters for macro 'SelectFont'
\afxbutton.h(184): error C2146: syntax error: missing ')' before identifier 'SelectObject'
\afxbutton.h(184): error C3646: 'SelectObject': unknown override specifier
\afxbutton.h(184): error C2146: syntax error: missing ')' before identifier 'pDC'
\afxbutton.h(184): error C2065: 'pDC': undeclared identifier
\afxbutton.h(184): error C2096: 'HFONT': A data member cannot be initialized with a parenthesized initializer
\afxbutton.h(184): error C2433: 'CMFCButton::HFONT': 'virtual' not permitted on data declarations
\afxbutton.h(184): error C2131: expression did not evaluate to a constant
\afxbutton.h(184): note: failure was caused by non-constant arguments or reference to a non-constant symbol
\afxbutton.h(184): note: see usage of 'pDC'
\afxbutton.h(184): error C2327: 'CMFCButton::HFONT': is not a type name, static, or enumerator
\afxbutton.h(184): error C2059: syntax error: ')'
\afxbutton.h(184): error C2091: function returns function
\afxbutton.h(203): error C2327: 'CMFCButton::HFONT': is not a type name, static, or enumerator
\afxfontcombobox.h(45): warning C4003: not enough actual parameters for macro 'SelectFont'
\afxfontcombobox.h(45): error C2146: syntax error: missing ')' before identifier 'SelectObject'
\afxfontcombobox.h(45): error C3646: 'SelectObject': unknown override specifier
\afxfontcombobox.h(45): error C2146: syntax error: missing ')' before identifier 'pDesc'
\afxfontcombobox.h(45): error C2065: 'pDesc': undeclared identifier
\afxfontcombobox.h(45): error C2096: 'HFONT': A data member cannot be initialized with a parenthesized initializer
\afxfontcombobox.h(45): error C2131: expression did not evaluate to a constant
\afxfontcombobox.h(45): note: failure was caused by non-constant arguments or reference to a non-constant symbol
\afxfontcombobox.h(45): note: see usage of 'pDesc'
\afxfontcombobox.h(45): error C2327: 'CMFCFontComboBox::HFONT': is not a type name, static, or enumerator
\afxfontcombobox.h(45): error C2059: syntax error: ')'
\afxfontcombobox.h(45): error C2091: function returns function
\afxfontcombobox.h(46): error C2146: syntax error: missing ')' before identifier 'SelectObject'
\afxfontcombobox.h(46): error C3646: 'SelectObject': unknown override specifier
\afxfontcombobox.h(46): error C2146: syntax error: missing ')' before identifier 'lpszName'
\afxfontcombobox.h(46): error C2065: 'lpszName': undeclared identifier
\afxfontcombobox.h(46): error C2096: 'HFONT': A data member cannot be initialized with a parenthesized initializer
\afxfontcombobox.h(46): error C2086: 'BOOL CMFCFontComboBox::HFONT': redefinition
\afxfontcombobox.h(45): note: see declaration of 'CMFCFontComboBox::HFONT'
\afxfontcombobox.h(46): error C2131: expression did not evaluate to a constant
\afxfontcombobox.h(46): note: failure was caused by non-constant arguments or reference to a non-constant symbol
\afxfontcombobox.h(46): note: see usage of 'lpszName'
\afxfontcombobox.h(46): error C2327: 'CMFCFontComboBox::HFONT': is not a type name, static, or enumerator
\afxfontcombobox.h(46): error C2059: syntax error: ')'
The culprit is #include "afxcontrolbars.h" which is auto added by the IDE. Not sure if I have to link to another version of ATL, change the include order, or what. Does anyone have an idea?
I moved the #include "afxcontrolbars.h" before any other afx includes and this resolved this issue.

Rewrite ERROR constant in C++

When trying to compile the following C++ code snippet (using Microsoft Visual Studio 2015):
namespace NS
{
const int ERROR = -1;
};
It returns the following error:
c:\workspace\X.hpp(141): error C2143: syntax error: missing ';' before 'constant'
c:\workspace\X.hpp(141): error C2059: syntax error: 'constant'
The constant ERROR is already defined somewhere, since if one makes the line a comment, ERROR can still be printed (it returns 0 for that matter).
I thought this type of collision could be avoid by defining a namespace.
How can one defined his/her own constant ERROR?

Visual C++ compiler, errors compiling stdlib.h

I am trying to compile a file which requires functions included from cmath. I do not believe my code itself to be at fault for causing this error, I suspect the configuration (it persists even with all of the non-include code commented), but have no idea what is going wrong. I am compiling on a Windows host, 64 bit. Other than adding the masm build configuration, I don't believe I've changed any compile settings to non-default, and the problem persists after disabling masm, and by setting the target configuration to 32 bit. Here is my generated output:
1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected
1>...\VStudio\VC\include\stdlib.h(467): error C2062: type 'long' unexpected
1>...\VStudio\VC\include\stdlib.h(467): error C2059: syntax error : ')'
1>...\VStudio\VC\include\stdlib.h(468): error C2143: syntax error : missing ';' before '{'
1>...\VStudio\VC\include\stdlib.h(468): error C2447: '{' : missing function header (old-style formal list?)
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected
1>...\VStudio\VC\include\stdlib.h(471): error C2062: type '__int64' unexpected
1>...\VStudio\VC\include\stdlib.h(471): error C2059: syntax error : ')'
1>...\VStudio\VC\include\stdlib.h(472): error C2143: syntax error : missing ';' before '{'
1>...\VStudio\VC\include\stdlib.h(472): error C2447: '{' : missing function header (old-style formal list?)
Any help would be greatly appreciated.
Edit:
I have found the troublesome line. Contrary to my expectation, the error does occur in the code, and is the fault of a line inherited from a previous version:
#define abs(a) ((a)<0? -(a):(a))
is responsible for my problems.
Next time, #include system headers before any of your own code. That way your macros can't mess with the system headers and lead you astray.

Some errors in VC++

I have a code that generates errors on my PC but does't on other PC.I have windows 7 installed and also installed the compatible SDK for windows 7.I have also included the VC directories (from Tools -> option-> vc Diretories) but still the code generates follwing errors.
error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'
error C2589: '(' : illegal token on right side of '::'
warning C4091: '' : ignored on left of 'const unsigned int' when no variable is declared
error C2143: syntax error : missing ';' before '::'
error C2059: syntax error : '::'
error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'
statement generating error are as following
static const unsigned int MAPVK_VK_TO_CHAR;
const unsigned int KeyLogger :: MAPVK_VK_TO_CHAR = 0x02;
Try selecting MAPVK_VK_TO_CHAR and hitting F12 to see if the symbol is declared elsewhere.
What's MAPVK_VK_TO_CHAR? I ask because the error might indicate that this is some macro.
Why do you make a plain identifier (not a macro) all caps, anyway? That's just begging for one of the thousands of macros in <windows.h> to trample over it. (Not that not making it all caps would prevent that, since <windows.h> sacrilegiously defines many mixed-case macros...)
Otherwise you would have to paste some minimal, compilable example showing the problem.