Giter Club home page Giter Club logo

Comments (8)

felselva avatar felselva commented on May 3, 2024 1

You can use true as long as you include <stdbool.h>

I'm checking how do I get the errors multiple storage classes in declaration specifiers.

Edit: testing on gcc (linux).

from cute_headers.

mmozeiko avatar mmozeiko commented on May 3, 2024 1

Yes, sure you can include stdbool.h for bool/true/false, but then dup should be bool, not int. And instead 0 it should be initialized with false :)

These gcc errors i posted is from Windows gcc, not Linux. On Linux _WIN32 is not defined, so that #ifdef chooses correct C2_INLINE value - with attribute always_inline.

from cute_headers.

mmozeiko avatar mmozeiko commented on May 3, 2024 1

That still doesn't fix GCC for Windows.
Proper way would be to change it to:

  #ifdef _MSC_VER
  	#define C2_INLINE __forceinline
  #else
	#define C2_INLINE inline __attribute__((always_inline))
  #endif

Although it is a very strange thing to specify so many inline things. I would suggest to drop always_inline/__forceinline because those things in most cases make code slower, not faster (because of larger code generated, now less code fits in L1 code cache).

from cute_headers.

RandyGaul avatar RandyGaul commented on May 3, 2024

Oh thanks for these catches! I've been using MSCV that does non-standard support even though the C compiler gets invoked -- so these are pretty helpful. How did you find them? Did you run gcc with some warning flags?

from cute_headers.

mmozeiko avatar mmozeiko commented on May 3, 2024

I found these issues when I compiled my C file with MSVC. Just have main.c that includes tinyc2.h and you'll see errors I mentioned.

If I compile with gcc, I get few more errors:

tinyc2.h:519:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE void c2MakeProxy( const void* shape, C2_TYPE type, c2Proxy* p )
 ^~~~~~
tinyc2.h:558:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE int c2Support( const c2v* verts, int count, c2v d )
 ^~~~~~
tinyc2.h:580:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE c2v c2L( c2Simplex* s )
 ^~~~~~
tinyc2.h:592:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE void c2Witness( c2Simplex* s, c2v* a, c2v* b )
 ^~~~~~
tinyc2.h:604:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE c2v c2D( c2Simplex* s )
 ^~~~~~
tinyc2.h:620:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE void c22( c2Simplex* s )
 ^~~~~~
tinyc2.h:651:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE void c23( c2Simplex* s )
 ^~~~~~
tinyc2.h: At top level:
tinyc2.h:1444:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE c2v c2CapsuleSupport( c2Capsule A, c2v dir )
 ^~~~~~
tinyc2.h: At top level:
tinyc2.h:1557:1: error: multiple storage classes in declaration specifiers
 static C2_INLINE void c2Incident( c2v* incident, const c2Poly* ip, c2x ix, const c2Poly* rp, c2x rx, int re )
 ^~~~~~

You cannot combine static with __forceinline with gcc. But you can combine static with __attribute__((always_inline)). So you need to change your C2_INLINE macro to something like this:

#ifdef _MSC_VER
	#define C2_INLINE __forceinline
#else
	#define C2_INLINE __attribute__((always_inline))
#endif

After that gcc is happy.

from cute_headers.

RandyGaul avatar RandyGaul commented on May 3, 2024

Ok great, I'll fix these up sometime soon and add you as a contributor. For now if you want to mess with the header just make some local changes :)

from cute_headers.

felselva avatar felselva commented on May 3, 2024

These gcc errors i posted is from Windows gcc, not Linux. On Linux _WIN32 is not defined, so that #ifdef chooses correct C2_INLINE value - with attribute always_inline.

Ok. Then the behaviour might be different on Linux (or it's a different GCC version). I was getting the following warning for every function with C2_INLINE:

warning: always_inline function might not be inlinable [-Wattributes]
 C2_INLINE ...

I found on GCC docs the following sintax:

GCC does not inline any functions when not optimizing unless you specify the ‘always_inline’ attribute for the function, like this:

/* Prototype.  */
inline void foo (const char) __attribute__((always_inline));

So I added the inline before the __attribute__:

#else
	#define C2_INLINE __attribute__((always_inline))
#endif

Changed to:

#else
	#define C2_INLINE inline __attribute__((always_inline))
#endif

The inline warning was solved.

Platform: Linux
Compiler: gcc 6.3.1

from cute_headers.

RandyGaul avatar RandyGaul commented on May 3, 2024

Should be all fixed!

from cute_headers.

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.