Giter Site home page Giter Site logo

Comments (5)

CurtisHx avatar CurtisHx commented on August 31, 2024 2

It looks like it's a difference in the way GCC and Visual Studio treat __VA_ARGS__. GCC expands __VA_ARGS___ before passing it into the macro. Visual Studio expands __VA_ARGS__ after passing it.

See this answer on Stack Overflow: http://stackoverflow.com/a/5530998

A fix is to force the macro expansion by wrapping macros taking in __VA_ARGS__ with this macro:

#define EXPAND (x) x

For example, the FAKE_VOID_FUNC call chain in fff.h goes from

#define FAKE_VOID_FUNC(...)     FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__)

#define FUNC_VOID_(N,...)     FUNC_VOID_N(N,__VA_ARGS__)

#define FUNC_VOID_N(N,...)     FAKE_VOID_FUNC ## N(__VA_ARGS__)

to

#define FAKE_VOID_FUNC(...)     EXPAND(FUNC_VOID_(PP_NARG_MINUS1(__VA_ARGS__), __VA_ARGS__))

#define FUNC_VOID_(N,...)     EXPAND(FUNC_VOID_N(N,__VA_ARGS__))

#define FUNC_VOID_N(N,...)     EXPAND(FAKE_VOID_FUNC ## N(__VA_ARGS__))

In addition, the PP_NARG_MINUS1 and PP_NARG_MINUS1_ macros need to be wrapped similarly.

I'm 99% confident this fix will work with GCC as well as VC++. I'm just not sure how to go about making the change in the ruby generation file.

from fff.

CurtisHx avatar CurtisHx commented on August 31, 2024

Tracking it down further (I don't have a solution yet...), it has to do with the way that the VC++ preprocessor expands (or lack thereof) of __VA_ARGS__. Of course Microsoft would have to do it differently from everyone else...

from fff.

shebaw avatar shebaw commented on August 31, 2024

You can explicitly use the numbered functions as a workaround.
Example:
FAKE_VALUE_FUNC1(void *, malloc, size_t)

from fff.

VincentDary avatar VincentDary commented on August 31, 2024

I work with gcc on linux and cl.exe on windows, the EXPAND trick work well for M$. Thank's

from fff.

meekrosoft avatar meekrosoft commented on August 31, 2024

Thanks for the contribution!

from fff.

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.