Giter VIP home page Giter VIP logo

Comments (7)

paoloambrosio avatar paoloambrosio commented on July 19, 2024

This is due to the fact that the compiler you are using does not support the __COUNTER__ macro. Take a look at include/cukebins/internal/RegistrationMacros.hpp:

#ifdef __COUNTER__
#define CUKE_GEN_OBJECT_NAME_ BOOST_JOIN(CukeObject, __COUNTER__)
#else
// Use a counter to be incremented every time cukebins is included
// in case this does not suffice (possible with multiple files only)
#define CUKE_GEN_OBJECT_NAME_ BOOST_JOIN(CukeObject, __LINE__)
#endif

from cucumber-cpp.

holledauer avatar holledauer commented on July 19, 2024

I use the gcc 4.2.1 from MacOS. It doesn't support the COUNTER macro.

It also doesn't work if you compile all source files serperately into .o files before linking.

Is it possible to include the file name into the object name?

from cucumber-cpp.

paoloambrosio avatar paoloambrosio commented on July 19, 2024

Legal characters for identifiers are letters, numbers, and _. The file name always includes at least one illegal character: the dot.

A workaround would be to include all your cpp files into a "global" one, but having to compile everything from scratch every time you change one file.

We might solve this issue by allowing the definition of a suffix in every file, by a define directive or a corresponding compiler parameter. A generated counter (followed by a legal character as the underscore) should not be difficult to add with cmake or scons.

from cucumber-cpp.

holledauer avatar holledauer commented on July 19, 2024

The suffix solution works. I did it exactly that way (but as prefix)*.
I added the following code to RegistrationMacros.hpp

#ifdef GEN_OBJECT_PREFIX
#define CUKE_GEN_OBJECT_NAME_ BOOST_JOIN(GEN_OBJECT_PREFIX,LINE)
#else

Then I used SCons to add the file name (without the suffix):

def buildObject(sourceFile):
return env.Object(
unicode('target/'+sourceFile.name[0:-4]+'.o'),
sourceFile,
CXXFLAGS='-DGEN_OBJECT_PREFIX=Object'+sourceFile.name[0:-4]
)

It would be great if you could add this solution to the official code base.

from cucumber-cpp.

paoloambrosio avatar paoloambrosio commented on July 19, 2024

Yes, that's exactly what I meant. I used CUKE_OBJECT_PREFIX instead of GEN_OBJECT_PREFIX because it's unlikely that anyone would want to name a macro in their code starting with CUKE :-) If not defined, it defaults to CukeObject as before.

from cucumber-cpp.

holledauer avatar holledauer commented on July 19, 2024

Great! Thanks

from cucumber-cpp.

rainexus avatar rainexus commented on July 19, 2024

can just add a anonymous namespace for each cpp file

from cucumber-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.