error while converting to cmake - kooldock.cpp - iostream
#2
Closed
opened 6 years ago by Ghost
·
15 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
While converting kooldock from automake to cmake I ran against this error:
/usr/include/c++/6.5.0/bits/basic_string.h: In member function 'int std::basic_string<_CharT, _Traits, _Alloc>::compare(const std::basic_string<_CharT, _Traits, _Alloc>&) const': /home/cethyel/Public/trinity-pot/CMAKECONV/kooldock/src/kooldock.cpp:66:19: error: expected unqualified-id before '(' token #define min(a, b) (a < b) ? (a) : (b)
I get rid of this error by removing "#include <iostream>" from kooldock.cpp
It builds fine and kooldock seems to be working fine but I'd like to have your view on the matter.
uhm.. sounds a bit weird to say the least. Although if it works.... 😄
I also tried with automake and kooldock builds fine without but I have basically no ideas where that include is needed.
I read that actually iostream loads a bunch of headers, if I could replace It with what is needed only, perhaps I won't run against that error (which is a blocker for the cmake conversion) while keeping everything to work as intended by the author of the code.
the problem is not the include file itself. it is understanding why there is no error in autotools and instead it comes up with an error when using cmake. There must be something going on that we are missing I guess.
I ran a quick search on the file with the usual/basic functions that (i)ostream provides but after 3/4 without result I just gave up.
I did a quick search through the code and it seems iostream include file is not required actually. Perhaps not the ideal solution, but it could be just simpler to remove that include file and continue instead of wasting time chasing this further, which is what you you suggested initially 😄
This problem could be casued by different compiling mode when switching from autotools to cmake.
Twice in the past I ran into issue when building a .c file and adding some includes and switching to .cpp. Or viceversa. Perhaps it is something like this.
Graham Seed in a book said that he not very fond of #define min or #define max as macro, instead he prefers templates such as this one:
template T max( T a, T b) { return a > b ? a : b ;}
on the other hand, I should give an other try with new parenthesis, from his book:
#define max(a, b) (( a > b ) ? a : b )
...to be continued!
Holly cow! Just ditch the macros and use std::min()/std::max() already…
@Fat-Zer
I usually don't touch the code because I've had little understanding of what's going on in programming in general but out of curiosity, I'll have a look on the links you've provided.
Anyhow, thanks for your input on the matter.
Feel free to help me out and submit a PR to get rid of those pesky macros.
@cethyel, lol, I knew that was coming... I'll base upon your
feat/cmakeConv
branch and PR directly to it to not to clobber with your pending PR if you don't mind...PS: nice work converting to cmake
Woops... @cethyel, it looks like I've accidentally pushed directly to
feat/cmakeConv
... I didn't suspected I've got the perms... I hope you don't mind... otherwise sorry about that...@Fat-Zer That's cool as It is, you rock man!
@Fat-Zer, you are included in the team of contributors, which means that you can push the branches directly into the main repositories == there is no need to make forks… as is described in the wiki for TDE Gitea Workspace.
Resolved by commits in #4 – thank you all for your cooperation!