Problème de compilation sur l'initialisation d'un pointeur de structure
Avec le code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| #include <stdio.h>
struct toto
{
unsigned int key;
char *value;
};
struct toto *key_values_private_ptr = (struct toto *)NULL;
key_values_private_ptr = (struct toto *)NULL; |
J'ai les erreurs suivantes :
Citation:
[~] The target is a file
gcc -o ../build/tests/unit/c/struct/field/struct_parameter_return.out ../build/tests/unit/c/struct/field/struct_parameter_return.c ../src/c/unknownFunction.c -I ../src/c -g
[~] Building with command: gcc -o ../build/tests/unit/c/struct/field/struct_parameter_return.out ../build/tests/unit/c/struct/field/struct_parameter_return.c ../src/c/unknownFunction.c -I ../src/c -g
../build/tests/unit/c/struct/field/struct_parameter_return.c:13:1: warning: data definition has no type or storage class
key_values_private_ptr = (struct toto *)NULL;
^~~~~~~~~~~~~~~~~~~~~~
../build/tests/unit/c/struct/field/struct_parameter_return.c:13:1: warning: type defaults to ‘int’ in declaration of ‘key_values_private_ptr’ [-Wimplicit-int]
../build/tests/unit/c/struct/field/struct_parameter_return.c:13:1: error: conflicting types for ‘key_values_private_ptr’
../build/tests/unit/c/struct/field/struct_parameter_return.c:10:14: note: previous definition of ‘key_values_private_ptr’ was here
struct toto *key_values_private_ptr = (struct toto *)NULL;
^~~~~~~~~~~~~~~~~~~~~~
../build/tests/unit/c/struct/field/struct_parameter_return.c:13:26: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
key_values_private_ptr = (struct toto *)NULL;
Je constate que
Code:
struct toto *key_values_private_ptr = (struct toto *)NULL;
compile sans souci
mais pas
Code:
key_values_private_ptr = (struct toto *)NULL;
J'avoue ne pas comprendre pourquoi...
Bonne journée