Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to config the headers in QtCreator? #6

Closed
Fokatu opened this issue Sep 17, 2021 · 3 comments
Closed

How to config the headers in QtCreator? #6

Fokatu opened this issue Sep 17, 2021 · 3 comments

Comments

@Fokatu
Copy link

Fokatu commented Sep 17, 2021

My system is Win 10, compiler is microsoft cl. I have enabled c++17 support.

When I try to compile the following code, I get syntax error

#include "h5pp/h5pp.h"

int main(int argc, char *argv[])
{

    h5pp::File file("example-01a-int.h5", h5pp::FilePermission::REPLACE); // Initialize a file

    return 0;
}

The errors are as follows:

C:\Users\zys\Documents\untitled\h5pp\details\h5ppFormat.h(36): warning C4081: expected '('; found 'string'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHid.h(175): error C2146: syntax error: missing ')' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHid.h(207): error C2146: syntax error: missing ')' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(242): error C2146: syntax error: missing '>' before identifier 'or'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(242): error C2187: syntax error: 'identifier' was unexpected here
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(272): error C2146: syntax error: missing '>' before identifier 'or'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(272): error C2187: syntax error: 'identifier' was unexpected here
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(275): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(275): error C2059: syntax error: 'std::is_same_v<T,h5pp::hid::h5t>'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppTypeSfinae.h(275): error C2187: syntax error: 'identifier' was unexpected here
C:\Users\zys\Documents\untitled\h5pp\details\h5ppDimensionType.h(36): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppDimensionType.h(36): error C2146: syntax error: missing ')' before identifier 'otherDims'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppDimensionType.h(36): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppDimensionType.h(36): error C2143: syntax error: missing ';' before 'throw'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(44): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(44): error C2146: syntax error: missing ')' before identifier 'is_regular'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(44): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(45): error C2143: syntax error: missing ';' before 'throw'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'offset'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'and': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'not'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'extent'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'and': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'not'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'stride'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'and': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'not'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(68): error C2146: syntax error: missing ';' before identifier 'blocks'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(72): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(72): error C2146: syntax error: missing ')' before identifier 'enable'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(72): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppHyperslab.h(72): error C2143: syntax error: missing ';' before 'return'
h5pp warning: could not find header <spdlog/spdlog.h>: A hand-made replacement logger will be used instead. Consider using spdlog for maximum performance
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(23): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(23): error C2146: syntax error: missing ')' before identifier 'smallDims'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(23): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(23): error C2143: syntax error: missing ';' before 'return'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(24): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(24): error C2146: syntax error: missing ')' before identifier 'largeDims'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(24): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(24): error C2143: syntax error: missing ';' before 'return'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(39): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(39): error C2146: syntax error: missing ')' before identifier 'ok'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(39): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(39): error C2146: syntax error: missing ';' before identifier 'msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2146: syntax error: missing ')' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2065: 'and': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2146: syntax error: missing ';' before identifier 'dims'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2146: syntax error: missing ';' before identifier 'and'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2065: 'and': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2146: syntax error: missing ';' before identifier 'dimsMax'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(56): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(55): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(75): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(75): error C2146: syntax error: missing ')' before identifier 'res1'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(75): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(75): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(75): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(76): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(76): error C2146: syntax error: missing ')' before identifier 'res2'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(76): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(76): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(76): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(77): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(77): error C2146: syntax error: missing ')' before identifier 'res3'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(77): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(78): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(77): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(101): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(101): error C2146: syntax error: missing ')' before identifier 'enable'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(101): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(101): error C2143: syntax error: missing ';' before 'return'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(122): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(122): error C2146: syntax error: missing ')' before identifier 'linkPath'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(122): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(122): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(124): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(124): error C2146: syntax error: missing ')' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(124): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(124): error C2143: syntax error: missing ';' before 'throw'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(124): warning C4834: discarding return value of function with 'nodiscard' attribute
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(144): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(144): error C2146: syntax error: missing ')' before identifier 'h5Space'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(144): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(144): error C2143: syntax error: missing ';' before 'return'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(153): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(153): error C2146: syntax error: missing ')' before identifier 'dataSize'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(153): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(153): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(154): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(154): error C2146: syntax error: missing ')' before identifier 'dataByte'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(154): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(154): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(155): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(155): error C2146: syntax error: missing ')' before identifier 'dataDims'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(155): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(155): error C2146: syntax error: missing ';' before identifier 'error_msg'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(156): error C2065: 'not': undeclared identifier
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(156): error C2146: syntax error: missing ')' before identifier 'dataRank'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(156): error C2059: syntax error: ')'
C:\Users\zys\Documents\untitled\h5pp\details\h5ppInfo.h(156): fatal error C1003: error count exceeds 100; stopping compilation
jom: C:\Users\zys\Documents\build-untitled-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\Makefile.Release [release\main.obj] Error 2
jom: C:\Users\zys\Documents\build-untitled-Desktop_Qt_5_15_2_MSVC2019_64bit-Release\Makefile [release] Error 2
08:59:00: 进程"C:\Qt\Tools\QtCreator\bin\jom\jom.exe"退出,退出代码 2 。
Error while building/deploying project untitled (kit: Desktop Qt 5.15.2 MSVC2019 64bit)
When executing step "Make"
08:59:00: Elapsed time: 00:01.

and the code corresponding to the first error is

[[nodiscard]] bool        equal(const hid_t &rhs) const final { return (val > 0 and rhs > 0 and H5Pequal(val, rhs)) or val == rhs; }
        
@DavidAce
Copy link
Owner

DavidAce commented Sep 17, 2021

Hi! The error seems to come from a couple of missing compile flags. If you are not using CMake, you should add the following to the MSVC compiler:

  • flag /permissive- for and/or logical operators
  • flag /EHsc for try/catch without warnings (I believe)
  • definition /D NOMINMAX for std::min and std::max to work as expected

These flags are applied and propagated as necessary when using CMake here. The full set of flags added by CMake and MSVC can be seen in the github actions build output:

cl /c /ID:\a\h5pp\h5pp\include /IC:\Users\runneradmin\.conan\data\eigen\3.4.0\_\_\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\include\eigen3 /IC:\Users\runneradmin\.conan\data\spdlog\1.9.2\_\_\package\5b1df17eadd1f81a71020461515f4af1686e577d\include /IC:\Users\runneradmin\.conan\data\fmt\8.0.1\_\_\package\157b7622dba188aff47602e51eaebfda53684339\include /IC:\Users\runneradmin\.conan\data\hdf5\1.12.0\_\_\package\83d29b61affb54f49fd1478ec437e6a0d8cfba27\include /IC:\Users\runneradmin\.conan\data\hdf5\1.12.0\_\_\package\83d29b61affb54f49fd1478ec437e6a0d8cfba27\include\hdf5 /IC:\Users\runneradmin\.conan\data\zlib\1.2.11\_\_\package\d057732059ea44a47760900cb5e4855d2bea8714\include /Zi /W1 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D SPDLOG_COMPILED_LIB /D SPDLOG_FMT_EXTERNAL /D NOMINMAX /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /GR /std:c++17 /Fo"h5pp-example-01c-struct-simple.dir\Debug\\" /Fd"h5pp-example-01c-struct-simple.dir\Debug\vc142.pdb" /external:W1 /Gd /TP /errorReport:queue "D:\a\h5pp\h5pp\examples\example-01c-struct-simple.cpp"

I should probably mention all this in the README. Please tell me if the flags above fixes the issue.

@Fokatu
Copy link
Author

Fokatu commented Sep 17, 2021

Thanks for your help!
After adding the flags, It is working now.

@DavidAce
Copy link
Owner

Great! I'll add the steps to the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants