Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflicting declaration

I have a typedef defined in my code as

typdef unsigned int size_t;

it is conflicting with stddef's

typedef __SIZE_TYPE__ size_t;

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

like image 797
user1496542 Avatar asked Aug 09 '12 18:08

user1496542


2 Answers

Two Three options:

1) Pick a different name, I think you already got that.

2) Use a namespace:

namespace X
{
   typedef long size_t;
}

and the type as

X::size_t x;

3) Ugly, guaranteed to get you fired, and me downvoted:

typedef unsigned int my_size_t;
#define size_t my_size_t
like image 63
Luchian Grigore Avatar answered Sep 18 '22 13:09

Luchian Grigore


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

like image 33
jwismar Avatar answered Sep 20 '22 13:09

jwismar