ARTICLE AD BOX
I am attempting to cast a log4cxx::FileInputStreamPtr to InputStreamPtr. On Windows using the Visual Studio 2019 compiler, this works without issue. My current implementation is:
log4cxx::helpers::Properties properties; log4cxx::helpers::InputStreamPtr inputStream = std::make_shared<log4cxx::helpers::FileInputStream>(resourceDirectory.string()); properties.load(inputStream);However, on Linux with GCC 8.5, the compiler throws the following error:
error: conversion from ‘std::shared_ptrlog4cxx::helpers::InputStream’ to non-scalar type ‘log4cxx::helpers::InputStreamPtr’ {aka ‘log4cxx::helpers::ObjectPtrTlog4cxx::helpers::InputStream’} requested log4cxx::helpers::InputStreamPtr inputStream = std::static_pointer_castlog4cxx::helpers::InputStream(fileInputStream);
I then tried the following approach:
std::shared_ptr<log4cxx::helpers::FileInputStream> fileInputStream = std::make_shared<log4cxx::helpers::FileInputStream>(resourceDirectory.string()); log4cxx::helpers::InputStreamPtr inputStream = std::static_pointer_cast<log4cxx::helpers::InputStream>(fileInputStream);Again, this compiles fine with Visual Studio 2019, but GCC produces a similar error:
error: conversion from ‘std::shared_ptrlog4cxx::helpers::InputStream’ to non-scalar type ‘log4cxx::helpers::InputStreamPtr’ {aka ‘log4cxx::helpers::ObjectPtrTlog4cxx::helpers::InputStream’} requested
Do you have any suggestions to resolve this issue? I understand the compiler version is quite old, but upgrading is not an option—I need to work with GCC 8.5.
