LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 06-11-2007, 06:29 AM   #1
Division_By_Zero
LQ Newbie
 
Registered: May 2007
Posts: 3

Rep: Reputation: 0
Question Casting Problem - Compiling code with g++ that works for gcc


Hi all!

I programmed a program that used a c-lib (pcap) compiles in gcc and runs perfectly. But i am not able to compile the same code in g++.
There is a single error, the error is in the line:

error: invalid use of member (did you forget the ‘&’ ?)

in my code:

pcap_loop(this->_handle, -1, (pcap_handler) my_pcap_handler, 0);

I've tried out:

pcap_loop(this->_handle, -1, (pcap_handler*) my_pcap_handler, 0);

and:

pcap_loop(this->_handle, -1, (pcap_handler&) my_pcap_handler, 0);

But it don't works!

defined in pcap.h as:

typedef void(* pcap_handler)(u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)

Any idea which I make can?

Thanks in advance.
 
Old 06-11-2007, 06:56 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
Could you please post a very tiny, complete program which:
  1. compiles without error when you say gcc fred.c -o fred; and
  2. demonstrates the error when you say g++ fred.c -o fred?
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem compiling code with g++ that works for gcc Division_By_Zero Programming 2 05-21-2007 02:19 AM
XAWTV works, videodog works, motion works but how to code my own? rylan76 Linux - Hardware 0 01-06-2006 06:30 AM
casting question in kernel source code linetnew Programming 3 04-18-2005 04:55 AM
Problem compiling code in g++ works for gcc juan_de_margo Programming 3 02-24-2005 03:41 AM
gcc warning compiling C code vose Programming 2 09-29-2004 10:58 AM


All times are GMT -5. The time now is 03:17 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration