Re: argv



YES there are two different calling conventions used in older win32
applications they push/pop the args in different orders in the assembler
part essentially.

http://unixwiz.net/techtips/win32-callconv.html
1)PASCAL calling convention(preferred legacy WINAPI calling convention)
"The other most popular convention is __stdcall. In it the parameters
are again pushed by the caller, but the stack is cleaned up by the
callee. It is the standard convention for Win32 API functions (as
defined by the WINAPI macro in <windows.h>), and it's also sometimes
called the "Pascal" calling convention."

2)C calling convention
"The default convention — shown above — is known as __cdecl."


The template win32 windows application uses the pascal calling convention:
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}


The template win32 console application uses the cdecl calling convention
for its main entry point unless told otherwise:
int main(int argc, char* argv[]) {
return 0;
}

So for your application code, does your main have:

int __cdecl main(int argc, char **argv)
{
 return 0;
}

or
int __stdcall main(int argc, char **argv)
{
 return 0;
}

gtk_init's calling convention doesn't specify either cdecl or stdcall.
The default gcc/g++ compiler uses is cdecl unless otherwise specified
elsewhere:
void gtk_init (int *argc, char ***argv);

I do hope this helps.

Cheers.


On 04/16/2016 02:03 PM, Andrew Robinson wrote:
Actually, I know exactly where argc and argv *SHOULD* be, just like they are
for every other C-based program that uses main(), but they either are not
really there, or they have been "corrupted". I know the way I have described
it sounds confusing, but I was just going overboard in trying to describe what
I was thinking the problem could be. It is confusing me why such a simple
thing won't work, when everything else does work.

On 4/16/2016 at 10:05 AM, Florian Pelz <pelzflorian pelzflorian de> wrote:
On 04/16/2016 06:50 PM, Andrew Robinson wrote:
Assembly language has no calling convention whatsoever until you hand code
it
to have whatever calling convention you want it to have, preferably
matching
the calling convention of whatever you are interfacing to.


This is not a matter of calling convention.

If I understand you correctly, your problem is that argc and argv are
not stored where you expect them to be. My (and your?) theory is that
argc and argv are not being set up the way you expect them to be.

However, it is *not* GTK+ that sets up argc and argv before your entry
point gets called. It is either the operating system or some
linker-generated machine code you don't normally get to see. That is,
not everything in your .exe file is part of your assembly code. This is
why I suggested you check GoLink documentation, GoDev forums and the
answers on Stack Overflow about GoLink instead of GTK+.

Have you actually ever programmed in assembly?


Yes.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]