Erreur sous visual

alphaone Messages postés 134 Date d'inscription vendredi 2 mai 2003 Statut Membre Dernière intervention 14 novembre 2009 - 24 mai 2009 à 08:26
alphaone Messages postés 134 Date d'inscription vendredi 2 mai 2003 Statut Membre Dernière intervention 14 novembre 2009 - 25 mai 2009 à 07:10
Je tante de compiler mon programme sous visual, avant je le fessait avec mingw et cella marché trés bien, voila mes erreurs:

1>.\main.cpp(375) : error C2057: expected constant expression
1>.\main.cpp(375) : error C2466: cannot allocate an array of constant size 0
1>.\main.cpp(375) : error C2133: 'temp' : unknown size
1>.\main.cpp(443) : warning C4309: 'initializing' : truncation of constant value
1>.\main.cpp(443) : warning C4309: 'initializing' : truncation of constant value
1>.\main.cpp(776) : error C2664: 'CreateFileW' : cannot convert parameter 1 from 'QStdWString' to 'LPCWSTR'
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>.\main.cpp(839) : error C2057: expected constant expression
1>.\main.cpp(839) : error C2466: cannot allocate an array of constant size 0
1>.\main.cpp(839) : error C2133: 'lpDirectoryName' : unknown size

main.cpp(375):
WCHAR temp[KeyValue.length()+1];

main.cpp(443):
char headerUtf16[2]={0xff,0xfe};

main.cpp(839):
WCHAR lpDirectoryName[mountPoint.length()*2];

Voila le prototype de la méthode:
int QString::length () const

Quelqu'un pourrai m'aider?

5 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
24 mai 2009 à 08:48
char headerUtf16[2]={0xff,0xfe};
Possibilité:
char headerUtf16[2];
*((WORD*) headerUtf16) = 0xFEFF;


WCHAR temp[KeyValue.length()+1];
On ne compile pas les inepties du C99 avec les outils MS.

ciao...
BruNews, MVP VC++
0
alphaone Messages postés 134 Date d'inscription vendredi 2 mai 2003 Statut Membre Dernière intervention 14 novembre 2009
24 mai 2009 à 09:43
Ce serai pas plutot:
*((WORD*) headerUtf16) = 0xFFFE;
?

On ne compile pas les inepties du C99 avec les outils MS.:
Pourquoi ce serai des inepties? Alors comment faire du propre?
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
24 mai 2009 à 11:40
Allocation dynamique (malloc)

Ligne 443 c'est un warning, mais t'a qu'a faire ca:
char headerUtf16[2]={(char)0xff,(char)0xfe};

_____________________________________
Un éditeur de ressources gratuit pour Windows
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
24 mai 2009 à 20:51
Avec
char headerUtf16[2]={0xff,0xfe};


c'est bien 0xFF que tu veux dans le 1er octet ?
si oui, c'est bien
*((WORD*) headerUtf16) = 0xFEFF;
LITTLE ENDIAN


Pourquoi des inepties ?
ben enfin, si on ne veut pas gérer la mémoire, on fait de l'interprété.

ciao...
BruNews, MVP VC++
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
alphaone Messages postés 134 Date d'inscription vendredi 2 mai 2003 Statut Membre Dernière intervention 14 novembre 2009
25 mai 2009 à 07:10
Je préfère c'est plus universelle et ça marche même sous unix:
char headerUtf16[2]={(char)0xff,(char)0xfe};
En plus il faut que je manipule un char * ...
0
Rejoignez-nous