delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/07/20/13:32:58

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
MIME-Version: 1.0
Subject: g++ problem when attempting to cast a function pointer in an OpenGL GLU callback
Date: Wed, 20 Jul 2005 12:32:40 -0500
Message-ID: <1075213EFAF9BA4181A250B072635947F14C8A@AMR-EX6.ds.amrdec.army.mil>
From: "Day, Michael A AMRDEC/UAH" <mike DOT a DOT day AT us DOT army DOT mil>
To: <cygwin AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j6KHWsVs002174

I've got a program I'm attempting to port from Red Hat Enterprise Linux 3 to Cygwin (on Windows).
 
g++ -v in Cygwin reveals: gcc version 3.4.4
g++ -v in Red Hat reveals: gcc version 3.2.3-52
 
There's the background.  Here's the problem:
 
I'm attempting to cast a function pointer in the following C++ code:
 
------------------------------------------
/* ... includes and what not ... */
 
void tcbBegin(GLenum prim) { 
    cout << "BEGIN"; 
}
 
/* ... */
 
void tessellateTest() {
 //Allocate a new GLU tessellation object
 GLUtesselator *tess = gluNewTess();
 
 //Assigning callbacks
 
 //begin callback
 gluTessCallback(tess,GLU_TESS_BEGIN, (void(*)()) tcbBegin);    // THIS IS LINE 71 //
 
/* ... */
--------------------------------------
 
When compiling, this error happens in Cygwin:
test.cpp:72: error: invalid conversion from `void (*)()' to `void (*)()'
 
No error occurs in Red Hat.  The cast works just fine, and I've used this code with no problem for several months.
 
Not casting at all results in this error (on both Red Hat and Cygwin):
test.cpp:71: error: invalid conversion from `void (*)(GLenum)' to `void (*)()'
 
My compile line in Cygwin looks like:
$ g++ test.cpp -lglu32 -lopengl32
 
And in Red Hat it looks like:
$ g++ test.cpp -lGLU -lGL

Any idea whats going on?  It seems to me that the cast should be legal.  Have the rules changed in g++ between the two versions? I have already tried using a reinterpret_cast, but that didn't work.
 
Thanks,
 
Mike Day
Virtual Targets Center
https://modelexchange.army.mil/
 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019