Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » explanation of c++ typedef line
explanation of c++ typedef line [message #18227] Thu, 18 September 2008 03:20 Go to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
Can someone explain to me this line:
typedef tagXYZHANDLE {} * XYZHANDLE;

My interpretation: 'XYZHANDLE is an alias of a pointer to an array of tagXYZHANDLE'? Is this correct?

It's from CodeProject article:
HowTo: Export C++ classes from a DLL
http://lamp.codeproject.com/KB/cpp/howto_export_cpp_classes. aspx


Re: explanation of c++ typedef line [message #18232 is a reply to message #18227] Thu, 18 September 2008 11:56 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
I don't know, but it doesn't compile. Perhaps an error?
Re: explanation of c++ typedef line [message #18235 is a reply to message #18227] Thu, 18 September 2008 14:27 Go to previous messageGo to next message
cas_ is currently offline  cas_
Messages: 20
Registered: July 2008
Location: Poland
Promising Member
captainc wrote on Thu, 18 September 2008 03:20


My interpretation: 'XYZHANDLE is an alias of a pointer to an array of tagXYZHANDLE'? Is this correct?


No, that would be:
typedef tagXYZHANDLE (*XYZHANDLE)[];
Re: explanation of c++ typedef line [message #18236 is a reply to message #18235] Thu, 18 September 2008 15:23 Go to previous messageGo to next message
captainc is currently offline  captainc
Messages: 278
Registered: December 2006
Location: New Jersey, USA
Experienced Member
This was one of the comments:
Quote:

typedef void* XYZHANDLE;
typedef void* IJKHANDLE;

is not type safe, since all handle will became mutually replaceable being all void*. (you can assign an XYZ to an IJK).

One way to get around this is to declare a category (empty struct) and point to it.

typedef struct XYZHANDLE_ {} *XYZHANDLE;
typedef struct IJKHANDLE_ {} *IJKHANDLE;


Now IJKHANDLE and XYZHANDLE cannot anymore be assigned each other.


Maybe the author replaced it incorrectly.
Re: explanation of c++ typedef line [message #18237 is a reply to message #18227] Thu, 18 September 2008 16:27 Go to previous message
mr_ped is currently offline  mr_ped
Messages: 794
Registered: November 2005
Location: Czech Republic - Praha
Contributor

There are more uncompilable things:
#include "XyzLibrary.h"
extern "C" XYZAPI IXyz* APIENTRY GetXyz();

(i.e. it's probably problem with quality of the article itself)

That line from first post really looks like missing "struct" keyword, that was also my first idea without reading the article.
Previous Topic: Time for little quiz!
Next Topic: Multiple statements in for loop
Goto Forum:
  


Current Time: Thu Apr 25 12:10:30 CEST 2019

Total time taken to generate the page: 0.00626 seconds