Communauté Informatique NDFR.net : probleme de macro avec cast !!! argh !!!!! - Programmation (C/C++, Delphi, VB, etc.)
Reply
probleme de macro avec cast !!! argh !!!!!
Thread Tools Display Modes
  #1  
Old 21-11-2003, 10:52
toasty62 toasty62 is offline
Membre junior
 
Join Date: 21-11-2003
Posts: 1
Exclamation probleme de macro avec cast !!! argh !!!!!

g un big pb ac une macro et je c pa trop d'ou ca vient... doit y avoir un pb de cast ou de pointeur...
voila le code :

typedef struct
{
char type;

union
{
float type0;
int type1;
};

} param;


#define GetIntFloat(variable) variable.type==0 ? variable.type0 : variable.type1


int main(int argc, char* argv[])
{
// pour les float
param paramFloat;
paramFloat.type = 0;
paramFloat.type0 = 123.4;

float f = GetIntFloat(paramFloat);

// pour les int
param paramInt;
paramInt.type = 1;
paramInt.type1 = 123;

int i = GetIntFloat(paramInt);

printf("float=%f\tint=%d\n", f,i);

system("pause");
return 0;
}

jusque là, ce code marche, mais si maintenant je change le printf par :
printf("float=%f\tint=%d\n", GetIntFloat(paramFloat), GetIntFloat(paramInt));

eh ben ca marche pu !
prtant au dessus le GetIntFloat retourne bien un float ou un int selon ce qui a ét décidé... ac ce printf, le GetIntFloat ne marche pas pr le INT...
snif... qqun pourrait-il m'aider svp ???
Reply With Quote
  #2  
Old 21-11-2003, 14:34
Benjy's Avatar
Benjy Benjy is offline
Administrateur
 
Join Date: 21-08-2001
Location: Rueil Malmaison (92)
Age: 43
Posts: 2,043
Send a message via MSN to Benjy
Re: probleme de macro avec cast !!! argh !!!!!

C'est sans doute une suggestion nulle, étant donné que ça fait 4 ans que je n'ai pas fait de C :

Code:
printf("float=%f\tint=%d\n", float GetIntFloat(paramFloat), int GetIntFloat(paramInt));
__________________
Merci de lire et de respecter les règles et d'utiliser la .
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cours de français Benjy Discussions sur le site et/ou le forum 47 01-05-2006 14:47
Petit probléme avec outlook express !!! Alexlesioux Internet, Réseaux et Sécurité 11 31-08-2004 07:16
Probleme de Raid avec MSI K7T266 Pro2 RU Lionel-78 Windows NT4/2000/XP Client 0 03-04-2003 12:01
Probléme de lenteurs... chalouf Discussions sur le site et/ou le forum 11 22-01-2003 19:37
Probleme site!! chalouf Discussions sur le site et/ou le forum 4 21-10-2002 21:06

All times are GMT +2. The time now is 22:13.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.