C language > Windows questions

Using incompatible types 'int __stdcall (*)(...) and 'long long int __stdcall (.

(1/3) > >>

finzi:
Hello,
I'm new in PellesC.
I'm using it to move my old programs form 32 to 64 bit.
Some of thes have problem at run time: i get an exception C000041D (don't know that is that).
The only significant worning while building is relevant to window or dialog creation:
warning #2145: Using incompatible types 'int __stdcall (*)(HWND, unsigned int, unsigned long long int, long long int)' and 'long long int __stdcall (*)(HWND, unsigned int, unsigned long long int, long long int)'.

Any suggestion?
Thanks,
Andrea

frankie:
Hello welcome  :)
32 and 64 bits versions of MS compiler have different sizes for standard types (i.e. a 'long' is 32 bits in 32bits compilation, and 64bits in 64bit case).
To compile one to one for 32 and 64 bits you must apply some small fixes, avoid to use basic types, and use predefined ones (DWORD, DWORD_PTR, INT, INT_PTR, etc.)
In your specific case give us more info, a code sample (short please!), to have a more detailed answer.

finzi:
Thank for the prompt reply   :)

The program is big and confused (I started developping it while learning C .....).
It is a finite element model viewer based on OpenGL.
It includes a menu system, and here is the problem:
the second call the the routine managing the menu (starting the second menu) generate the access violation, calling CreateWindow.

In 32 bit everythink worck fine.
 
Annex. the routine and the structure where menue information are store.

Thank you very much for the support,
Andrea


--- Code: ---int ReturnMenu(F_menu *m)
{
static unsigned int   first=0;
hInst=GetModuleHandle(NULL);

if(!first){
base_color=CreateSolidBrush(m->base_color);
if(InitMenu()){
first=1;
Menu_level=0;
}
}
else{
if(Menu_level==DLGINPUT_MAX_level-1){
MessageBox(m->parent,"Too many menu levels!","MENU",MB_OK);
return 0;
}
Menu_level++;
}

ghF_menu[Menu_level]=m;

if(m->Prop==0){
gProp=1;
}
else if(m->Prop<0){
gProp=-1.0/m->Prop;
}
else{
gProp=m->Prop;
}
gWidth=(m->Width-3*spazio)*gProp/(gProp+1);

gParent=m->parent;
strcpy(gitem_description,m->comando);
strcpy(gresults,m->inizio);

Menu_ID[Menu_level]=m->menu_id;
Menu_Type[Menu_level]=m->menu_type;
if(m->wtitle)strcpy(gwtitle[Menu_level],m->wtitle);
if(m->min_lines)gmin_lines=m->min_lines;


        //Here the access violation generates
hwndMenus[Menu_level]=CreateWindow("win_menu",m->wtitle,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|WS_BORDER,
m->x,m->y,200,200,
m->parent,
NULL,
hInst,
NULL);

                 if(Menu_level)ShowWindow(hwndMenus[Menu_level-1], SW_HIDE);

return (int)hwndMenus[Menu_level];
}

// Menu
typedef struct tagF_menu {
char wtitle[80];
int menu_id;
int menu_type;
char comando[DLGINPUT_MAX];
char inizio[DLGINPUT_MAX];
char risultato[DLGINPUT_MAX];
int Width;
int Prop;
HWND parent;
int x;
int y;
int min_lines;
int docking;
COLORREF base_color;
} F_menu;

static HWND hwndMenus[DLGINPUT_MAX_level];


--- End code ---

finzi:
Example

frankie:
How is defined 'hinst'?
Why you cast 'HWND' types to int?
These are incorrect also in 32bits programming. It could eventually work if, in 32bits, those types are <= 32bits wide.
Use the correct types:

--- Code: ---HWND ReturnMenu(F_menu *m)
{
static unsigned int   first=0;
HINST  hInst=GetModuleHandle(NULL);

if(!first){
base_color=CreateSolidBrush(m->base_color);
if(InitMenu()){
first=1;
Menu_level=0;
}
}
else{
if(Menu_level==DLGINPUT_MAX_level-1){
MessageBox(m->parent,"Too many menu levels!","MENU",MB_OK);
return 0;
}
Menu_level++;
}

ghF_menu[Menu_level]=m;

if(m->Prop==0){
gProp=1;
}
else if(m->Prop<0){
gProp=-1.0/m->Prop;
}
else{
gProp=m->Prop;
}
gWidth=(m->Width-3*spazio)*gProp/(gProp+1);

gParent=m->parent;
strcpy(gitem_description,m->comando);
strcpy(gresults,m->inizio);

Menu_ID[Menu_level]=m->menu_id;
Menu_Type[Menu_level]=m->menu_type;
if(m->wtitle)strcpy(gwtitle[Menu_level],m->wtitle);
if(m->min_lines)gmin_lines=m->min_lines;


        //Here the access violation generates
hwndMenus[Menu_level]=CreateWindow("win_menu",m->wtitle,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP|WS_BORDER,
m->x,m->y,200,200,
m->parent,
NULL,
hInst,
NULL);

                 if(Menu_level)
                     ShowWindow(hwndMenus[Menu_level-1], SW_HIDE);

return hwndMenus[Menu_level];
}

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version