Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 28th, 2006, 7:17 AM   #1
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
GCC Linux question

Yeah...its me trobouling you lot again.

Wots wrong in this:
typedef struct {

		void (__stdcall * StringCallback)(char  * string);

		void (__stdcall * IntCallback)(int eint);

	} CallbacksGalore;

in gcc:
g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)

I mean...used to work fine in windows vc++...

Thanks in advance
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Old Apr 28th, 2006, 7:41 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 893
Rep Power: 4 The Dark is on a distinguished road
Good question, whats wrong with it?
If you are getting errors from gcc, why not put them here to save us having to guess.
The Dark is offline   Reply With Quote
Old Apr 28th, 2006, 8:46 AM   #3
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
so gcc is not meant to support function pointers?
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Old Apr 28th, 2006, 9:38 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by rsnd
so gcc is not meant to support function pointers?
Of course it is meant to support them, he meant, post your gcc errors.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Apr 28th, 2006, 10:48 AM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
__stdcall is a compiler specific extension (specific to vc++ and a couple of other compilers that target windows, anyway) not supported by gcc.
grumpy is offline   Reply With Quote
Old Apr 28th, 2006, 8:43 PM   #6
rsnd
Hobbyist Programmer
 
rsnd's Avatar
 
Join Date: Jun 2005
Location: Helltown
Posts: 162
Rep Power: 4 rsnd is on a distinguished road
But its supposed to work on linux!!! http://www.programmersheaven.com/2/Calling-conventions
__________________
Spread your wings and fly! Chicken!
rsnd is offline   Reply With Quote
Old Apr 28th, 2006, 10:08 PM   #7
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
Even if you accept that link as definitive (which I don't), it describes calling conventions supported by compilers, not the means of tickling a compiler to use them.

In any event, there is no point in bleating if a compiler complains when you try to use something like __stdcall. __stdcall is openly a compiler specific extension. In this Microsoft did the right thing: names with one or more leading underscores fall into a set reserved by the C and C++ standards for compiler specific extensions. There is no requirement for other compilers to support such extensions.

Your solution is to remove the __stdcall qualifier.

If you want to be sensitive to compilers (or, more accurately, libraries that insist on using extensions like __stdcall) that require you to use __stdcall, then use macros to help.

#if defined(WHATEVER_MACRO_IDENTIFIES_YOUR_COMPILER)
#define STDCALL __stdcall
#elif defined (__GNUG__)     /*  gcc  IIRC */
#define STDCALL
#endif

typedef struct {

		void (STDCALL * StringCallback)(char  * string);

		void (STDCALL * IntCallback)(int eint);

	} CallbacksGalore;
Personally, I wouldn't do it this way as it sprinkles compiler dependencies into all functions that use your CallbacksGalore type, but this is one quick fix for amateurs.
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:40 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC