LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2004, 05:23 AM   #1
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Rep: Reputation: 15
Question Problems when porting code from C++ under visual studio 6 to linux.


Hello everyone,
I have a problem with some code in C++.
when i compile it under visual studio 6 everything is ok.
but when i compile it with gcc... well....
what i do is define a function pointer the following way:
i have a class called CCollect that collects function pointers.
the following line is inside that class:
Code:
public:
    typedef void (CCollect::*TFunction)()
now what i want to do is to take a funciton
Code:
void foo(CSomeClass* ptr, int nParam)
{
    ...
}
and i try to assign this function's address in a variable of type TFunction;

Code:
CCollect::TFunction pFunc = (CCollect::TFunction)foo
this works just fine in visual studio, but gcc simply gives me the following error:
"no matches converting function 'foo' to type 'void class CCollect::*'().
candidates are: void foo(CSomeClass* ptr, int nParam)"

any idea why that happens?

Thanks
 
Old 08-26-2004, 05:55 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hi there
i have been using 'g++' instead of 'gcc' to compile C++ programs in linux and they have been working fine
try
g++

regards
 
Old 08-26-2004, 06:05 AM   #3
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
Thanks for the reply.
i am using g++ already since i am compiling c++ code.
tried different versions (2.96, 3.1) of the compiler, nothing changed that error.
 
Old 08-26-2004, 07:19 AM   #4
Stor_G
Member
 
Registered: Aug 2004
Posts: 50

Original Poster
Rep: Reputation: 15
Ok problem solved.
problem was foo was a part of a class CFooClass.
and the code used several macros to make the conversions.
when i looked at the code after preprocessing, i saw that it wrote foo instead of CFooClass::foo, so it didn't recognize the function.
i wonder how it worked in visual studio though... probably the compiler assumed the right context or something...
thanks for the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio.NET in Linux RySk8er30 Linux - Software 3 05-27-2009 04:11 PM
Stupid Question: Microsoft Visual Studio 6.0 (A.K.A. Visual Basic 6) Will it run? S0RD3N Linux - Software 8 05-07-2008 08:42 PM
install visual studio 6.0 in linux trilochan Linux - Software 2 09-21-2003 10:15 AM
Linux clone for Visual Studio? JIV Programming 4 04-17-2003 09:06 PM
Is Visual Studio in Linux??? rob99 Linux - Software 6 01-22-2003 04:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration