Comments (8)
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.
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.
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.
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.
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.
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.
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.
Should be all fixed!
from cute_headers.
Related Issues (20)
- [cute_sound.h v2.x] Support multiple contexts. HOT 2
- http://randygaul.net is taken over by squatters HOT 1
- cute_net.h times out over the internet HOT 5
- Dynamically set panning for an individual playing sound HOT 2
- cute_aseprite.h - v1.3 Tilesets Discussion HOT 4
- cute_aseprite.h - Aseprite v1.3 property map support
- Cute_tiled "staggered" causes warning HOT 1
- inclusion of infinite maps and chunks HOT 3
- c2TOI returning wrong contact point
- cute_tls - allow ignoring certificate errors HOT 1
- cute_tiled: Force loading RGBA for tintedcolor
- cute_tiled: object `type` field HOT 4
- cute_2d c2PolytoPolyManifold issue HOT 2
- [Cute_Net.h] Knowing if a packet has been sent. HOT 3
- [cute_tiled_h]: Field `name` points to wrong memory address. HOT 2
- cute_aseprite.h "warning C4456: declaration of 'frame' hides previous local declaration"
- Usage of c2x and rotation HOT 1
- cute_aseprite.h crash with both 9-slice and pivot enabled. HOT 1
- cute_sound 2.x has no equivalent of 1.x cs_stop_sound
- cute_aseprite Crash on tags user data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cute_headers.