Conflict Declaration

I have a typedef defined in my code as

typdef unsigned int size_t;

it contradicts stddef

typedef __SIZE_TYPE__ size_t;

I'm not sure how to get around this, but would still like to keep size_t in my code.

+5
source share
2 answers

Two Three options:

1) Choose a different name, I think you already got it.

2) Use namespace:

namespace X
{
   typedef long size_t;
}

and type like

X::size_t x;

3) Awful, guaranteed that you fired me, and I said:

typedef unsigned int my_size_t;
#define size_t my_size_t
+18
source

It is probably a bad idea to try to override the type that is in one of the standard headers. What are you trying to achieve? Why don't you want to use the standard definition of size_t?

+2
source

All Articles