cpp-dotenv icon indicating copy to clipboard operation
cpp-dotenv copied to clipboard

Cannot compile with clang

Open techbech opened this issue 5 years ago • 3 comments

Building with clang fails because of the naming collision between the namespace dotenv and the class dotenv.

Version

clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Some of the build errors

***/cpp-dotenv/src/dotenv.cpp:14:1: error: reference to 'dotenv' is ambiguous
dotenv::dotenv& dotenv::dotenv::load_dotenv(const string& dotenv_path, const bool overwrite, const bool interpolate)
^
***cpp-dotenv/src/Parser.h:13:11: note: candidate found by name lookup is 'dotenv'
namespace dotenv
          ^
***/cpp-dotenv/include/dotenv.h:9:11: note: candidate found by name lookup is 'dotenv::dotenv'
    class dotenv
          ^
***/cpp-dotenv/src/dotenv.cpp:14:17: error: reference to 'dotenv' is ambiguous
dotenv::dotenv& dotenv::dotenv::load_dotenv(const string& dotenv_path, const bool overwrite, const bool interpolate)
                ^

Solution could be to rename the dotenv class #22

techbech avatar Dec 20 '20 15:12 techbech

Yep, I've found myself in that situation a couple of times (not with clang but with g++) and managed to sort it out eventually, but didn't think the problem would appear again.

Definitely renaming seems the way to go to avoid further headaches.

adeharo9 avatar Jan 15 '21 08:01 adeharo9

I think I'm going to go for something more like renaming the namespace (cppdotenv maybe, I don't know yet) and introduce a similar, coherent scoping structure in CMake (basing myself in the already-stable interfaces of good projects like this one).

Probably will introduce these changes for v1.0.0-beta and try to stabilize the interface at that version so v1.0.0 can be out and stable as soon as possible.

adeharo9 avatar Jan 15 '21 08:01 adeharo9

Hey, could not use a library because of this issue, I used dotenv-cpp lib.

cieslarmichal avatar Jan 01 '23 12:01 cieslarmichal