Category : casting

Piece of code compiles fine in Solaris 10 but fails in Solaris 11 DeveloperStudio 12.5. Error: Cannot cast from DOM_Node to const DOM_XMLDecl&. Code : xml->root_node = (const DOM_XMLDecl&)(xml->doc.getFirstChild()); If I change the code to (stupid though): xml->root_node = (xml->doc.getFirstChild()); Error: Cannot assign DOM_Node to DOM_XMLDecl without "DOM_XMLDecl::operator=(const DOM_XMLDecl&)";. This code compiles fine in Solaris ..

Read more

I am not an expert when it comes to using C++ so I need a little help here. Consider the following code: float thresh = 3.0; string threshold = to_string(thresh); cout<<strlen(threshold)<<endl; The terminal shows this error: error: cannot convert ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘const char*’ for argument ‘1’ to ‘size_t strlen(const char*)’ cout<<strlen(threshold)<<endl; What am ..

Read more

Ahh, nothing like the pre-C99 C standard… Where the following code just worked on little-endian machines: union UNION_WORD { WORD word; BYTE bytes[2]; }; union UNION_WORD test; test.word = 24576; test.bytes[0] = 8; And the data stored in test would be equivalent to 24584 when reading test.word. Sadly this behavior is undefined today in C ..

Read more