Menu

#26 Error-codes should be constants

open
nobody
None
5
2013-01-28
2012-03-13
Mikhail T.
No

Although the error-codes (such as EINVSOCK) are, in fact, constant, because they are declared as integer values, the compiler (tested with g++) does not recognize them as such. For example, this code:

switch (UDT::close(u)) {
case 0:
return 0;
case CUDTException::EINVSOCK:
return ENOTSOCK;
default:
return EDOOFUS;
}

causes the following error:
g++46 -fpic -DPIC -I/opt/include -I/opt/include/tcl8.6 -c /home/mi/tcl-udt/tclUdtChan.cpp -o tclUdtChan.So
...
tclUdtChan.cpp:41:22: error: 'CUDTException::EINVSOCK' cannot appear in a constant-expression

Could the error-codes be turned into enum? The API and the ABI need not change... Would you like a patch?

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.