Can't compile at VC++ Express Edition 2008

Hi I just switched to window programming. I have a code which I can
compile and run under Unix, but I cant compile it at Window VC++
Express Edition 2008. Here is some part of my code

cpp-trick.h

#if !defined(PACKET) || !defined(INTEGER) || !defined(STRING)
#error Not all necessary macros were defined.
#endif

PACKET(Auth,
        STRING(username)
        STRING(password)
)

PACKET(Ack,
        INTEGER(status)
        STRING(error_text)
)

#undef PACKET
#undef INTEGER
#undef STRING


typedef enum {
        #define INTEGER(name)
        #define STRING(name)
        #define PACKET(name, fields) name,
        #include "cpp_trick.h"
} PacketType;

char *type_name(PacketType type) {
        #define INTEGER(name)
        #define STRING(name)
        #define PACKET(name, fields) \
                if (type == name) return #name;
        #include "cpp_trick.h"
        return "unknown";
}


typedef struct Packet {
        PacketType type;
        #define INTEGER(name) int name;
        #define STRING(name) char *name;
        #define PACKET(name, fields) struct name { fields } name;
        #include "cpp_trick.h"
} Packet;


Packet *packet_create(PacketType type) {
        Packet *packet;

        packet = (Packet *)xmalloc(sizeof(Packet));
        packet->type = type;

        #define INTEGER(name) p->name = 0;
        #define STRING(name) p->name = NULL;
        #define PACKET(name, fields) \
                { struct name *p = &packet->name; fields }
        #include "cpp_trick.h"

        return packet;
}

when I compile it gives me errors like, I have changed Unicode to be
NOT_SET
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2440:
'initializing' : cannot convert from 'Packet::Auth *' to
'packet_create::Auth *'
1>        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
use of undefined type 'packet_create::Auth'
1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
declaration of 'packet_create::Auth'
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
left of '->username' must point to class/struct/union/generic type
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
use of undefined type 'packet_create::Auth'
1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
declaration of 'packet_create::Auth'
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
left of '->password' must point to class/struct/union/generic type
1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(13) : error C2440:
'initializing' : cannot convert from 'Packet::Ack *' to
'packet_create::Ack *'
1>        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast

what should I change?

Thanks a lot!
0
12/14/2008 5:46:51 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
432 Views

Similar Articles

[PageSpeed] 0

<wudehui2006@gmail.com> wrote in message 
news:566e1a2e-42cc-40f0-889e-fea340185371@o4g2000pra.googlegroups.com...
> Hi I just switched to window programming. I have a code which I can
> compile and run under Unix, but I cant compile it at Window VC++
> Express Edition 2008. Here is some part of my code
>
<snip>
> what should I change?
>
> Thanks a lot!

What project type?

0
pvdg421 (3)
12/15/2008 7:13:55 PM
It would help if you identified line 8, or showed the definition of PACKET, or STRING.
				joe

On Sun, 14 Dec 2008 09:46:51 -0800 (PST), wudehui2006@gmail.com wrote:

>Hi I just switched to window programming. I have a code which I can
>compile and run under Unix, but I cant compile it at Window VC++
>Express Edition 2008. Here is some part of my code
>
>cpp-trick.h
>
>#if !defined(PACKET) || !defined(INTEGER) || !defined(STRING)
>#error Not all necessary macros were defined.
>#endif
>
>PACKET(Auth,
>        STRING(username)
>        STRING(password)
>)
>
>PACKET(Ack,
>        INTEGER(status)
>        STRING(error_text)
>)
>
>#undef PACKET
>#undef INTEGER
>#undef STRING
>
>
>typedef enum {
>        #define INTEGER(name)
>        #define STRING(name)
>        #define PACKET(name, fields) name,
>        #include "cpp_trick.h"
>} PacketType;
>
>char *type_name(PacketType type) {
>        #define INTEGER(name)
>        #define STRING(name)
>        #define PACKET(name, fields) \
>                if (type == name) return #name;
>        #include "cpp_trick.h"
>        return "unknown";
>}
>
>
>typedef struct Packet {
>        PacketType type;
>        #define INTEGER(name) int name;
>        #define STRING(name) char *name;
>        #define PACKET(name, fields) struct name { fields } name;
>        #include "cpp_trick.h"
>} Packet;
>
>
>Packet *packet_create(PacketType type) {
>        Packet *packet;
>
>        packet = (Packet *)xmalloc(sizeof(Packet));
>        packet->type = type;
>
>        #define INTEGER(name) p->name = 0;
>        #define STRING(name) p->name = NULL;
>        #define PACKET(name, fields) \
>                { struct name *p = &packet->name; fields }
>        #include "cpp_trick.h"
>
>        return packet;
>}
>
>when I compile it gives me errors like, I have changed Unicode to be
>NOT_SET
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2440:
>'initializing' : cannot convert from 'Packet::Auth *' to
>'packet_create::Auth *'
>1>        Types pointed to are unrelated; conversion requires
>reinterpret_cast, C-style cast or function-style cast
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
>use of undefined type 'packet_create::Auth'
>1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
>declaration of 'packet_create::Auth'
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
>left of '->username' must point to class/struct/union/generic type
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
>use of undefined type 'packet_create::Auth'
>1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
>declaration of 'packet_create::Auth'
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
>left of '->password' must point to class/struct/union/generic type
>1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(13) : error C2440:
>'initializing' : cannot convert from 'Packet::Ack *' to
>'packet_create::Ack *'
>1>        Types pointed to are unrelated; conversion requires
>reinterpret_cast, C-style cast or function-style cast
>
>what should I change?
>
>Thanks a lot!
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
12/15/2008 7:44:04 PM
See below
"wudehui2006@gmail.com" wrote:

> Hi I just switched to window programming. I have a code which I can
> compile and run under Unix, but I cant compile it at Window VC++
> Express Edition 2008. Here is some part of my code
> 
> cpp-trick.h
> 
> #if !defined(PACKET) || !defined(INTEGER) || !defined(STRING)
> #error Not all necessary macros were defined.
> #endif
> 
> PACKET(Auth,
>         STRING(username)
>         STRING(password)
> )
> 
> PACKET(Ack,
>         INTEGER(status)
>         STRING(error_text)
> )
> 
> #undef PACKET
> #undef INTEGER
> #undef STRING
> 
> 
> typedef enum {
>         #define INTEGER(name)
>         #define STRING(name)
>         #define PACKET(name, fields) name,
>         #include "cpp_trick.h"
> } PacketType;
> 
> char *type_name(PacketType type) {
>         #define INTEGER(name)
>         #define STRING(name)
>         #define PACKET(name, fields) \
>                 if (type == name) return #name;
>         #include "cpp_trick.h"
>         return "unknown";
> }
> 
> 
> typedef struct Packet {
>         PacketType type;
>         #define INTEGER(name) int name;
>         #define STRING(name) char *name;
>         #define PACKET(name, fields) struct name { fields } name;
>         #include "cpp_trick.h"
> } Packet;
> 
> 
> Packet *packet_create(PacketType type) {
>         Packet *packet;
> 
>         packet = (Packet *)xmalloc(sizeof(Packet));
>         packet->type = type;
> 
>         #define INTEGER(name) p->name = 0;
>         #define STRING(name) p->name = NULL;
>         #define PACKET(name, fields) \
>                 { struct name *p = &packet->name; fields }
>         #include "cpp_trick.h"
> 
>         return packet;
> }
> 
> when I compile it gives me errors like, I have changed Unicode to be
> NOT_SET
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2440:
> 'initializing' : cannot convert from 'Packet::Auth *' to
> 'packet_create::Auth *'
> 1>        Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
> use of undefined type 'packet_create::Auth'
> 1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
> declaration of 'packet_create::Auth'
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
> left of '->username' must point to class/struct/union/generic type
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2027:
> use of undefined type 'packet_create::Auth'
> 1>        d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : see
> declaration of 'packet_create::Auth'
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(8) : error C2227:
> left of '->password' must point to class/struct/union/generic type
> 1>d:\development\xmacrotest\xmacrotest\cpp_trick.h(13) : error C2440:
> 'initializing' : cannot convert from 'Packet::Ack *' to
> 'packet_create::Ack *'
> 1>        Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
> 
> what should I change?
> 
> Thanks a lot!
> 

Taking a look at what the compiler sees after all the preprocessing:

typedef enum {
Auth,
Ack,
} PacketType;
char *type_name(PacketType type) {
if (type == Auth) return "Auth";
if (type == Ack) return "Ack";
        return "unknown";
}
typedef struct Packet {
        PacketType type;
struct Auth { char *username; char *password; } Auth;
struct Ack { int status; char *error_text; } Ack;
} Packet;
Packet *packet_create(PacketType type) {
        Packet *packet;
        packet = (Packet *)xmalloc(sizeof(Packet));
        packet->type = type;
{ struct Auth *p = &packet->Auth; p->username = 0; p->password = 0; }
{ struct Ack *p = &packet->Ack; p->status = 0; p->error_text = 0; }
        return packet;
}


It looks me like you've got several names being used as differing types.

Auth is an enum, a member as well as a struct identifier.  It is 
unsurprising that the compiler doesn't like it.
0
12/16/2008 4:21:02 PM
Reply:

Similar Artilces:

VC++ and access
Hello sir, I am now developing one Interactive Voice Response system. I want to add and retrive the values in the access table by using the telephone.I have used the dialogic card for that . Could u please help me to solve this problem by giving me one example appliction.As soon as possible. Thanking you.. Regards Shweta csshweta@gmail.com wrote: > Hello sir, > I am now developing one Interactive Voice Response system. > I want to add and retrive the values in the access table by using the > telephone.I have used the dialogic card for that . > Could u please help me to ...

locked for editing #3
due to some mistake of mine occasionally the excel file gets locked for editing and I am not able to save etc. I have to save it in different name and then reboot computer and delete old file and rename the new file to old file . I am not able to trace what mistake I do. can anybody suggest possible mistakes. I am from the MS Excel support department at http://www.enterpriseprojectconsulting.com and we would be happy to assist you in resolving your issue Thank you Enterprise Project Consultin If you "Protect" a range of cells or a workbook, access is denied. On the toolbar ...

Gettin a compile error
error C2229: struct '__unnamed' has an illegal zero-sized array i am getting above error for this " unsigned char buffer[4096]; " at this line static int iax_send(struct iax_session *pvt, struct ast_frame *f, unsigned int ts, int seqno, int now, int transfer, int final) { /* Queue a packet for delivery on a given private structure. Use "ts" for timestamp, or calculate if ts is 0. Send immediately without retransmission or delayed, with retransmission */ struct ast_iax2_full_hdr *fh; struct ast_iax2_mini_hdr *mh; struct { ...

Windows 2008 Event Log
Platform: Windows 2008, VC++ 2005 Hi, I am working on an application which will retrieve all the events from the available channels on a Windows 2008 or Vista. How do i get the list of custom event log channels available on the system? Thanks in Advance, Sudhish K V. Probably from the Registry, but that's just a guess. joe On Sat, 26 Jan 2008 12:32:56 +0530, "Sudhish K V" <sudhishkv@livehelper.com> wrote: >Platform: Windows 2008, VC++ 2005 > >Hi, >I am working on an application which will retrieve all the events from the >available channels on a ...

KB292249 is not fixed in Outllook Editions (2003) or XP
The problem reported in KB292249 is not fixed in Outlook 2003, Outlook XP, for that matter any past Outlooks. Is there a plan to fix it in a service pack? This is the most annoying bug ever for POP users and shows time and again that Microsoft software programmers are unable to write multi-threaded programs properly. -Pawan ...

Data Analysis Toolpak for Student Treacher edition originaly insta
I bought a laptop with the MSOffice 2007 Student Teacher edition as an original installation. I can't see how do add the Dala Analysis Toolpak. Does anyone have any advice please? Office ball > Excel Options > Addins Now locate "Manage AddIns" and select Toolpac best wishes -- Bernard Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme REMINDER: These newsgroups are about to die. We will all meet again at http://social.answers.microsoft.com/Forums/en-US/category/officeexcel "pjjenz" <pjjenz@discussions.microsoft.com> wrote in messa...

outlook express 6.0 #5
starting this morning every time I open OE, approx. 30 seconds later I recieve the following message : OE has encountered a problem and needs to close. I realize this is pretty vague but could someone try to point me in the right direction to try and correct this. I use norton anti-virus and just did a hard drive scan on 1-2-04 that came back fine, and i have NOT added any new programs to my computer for quite some time. thanks in advance. j <anonymous@discussions.microsoft.com> wrote: > starting this morning every time I open OE, approx. 30 > seconds later I recieve the ...

I can not open doc file attachments from outlook express 6.0
I can not open doc file attachments in outlook express 6.0 Error message - There is not enough memory to open file All other attachments eg: jpeg etc are fine I have already increased my paging memory. >-----Original Message----- >I can not open doc file attachments in outlook express 6.0 >Error message - There is not enough memory to open file >All other attachments eg: jpeg etc are fine=20 >I have already increased my paging memory. >. > These Newsgroups address Office Outlook issues. Outlook Express gurus hang out here: http://communities.microsoft.com/newsgroups/def...

Public Contacts Folder
I have users who have edit permissions on a public contact folder. They can create new contacts and Edit some contacts, BUT there are some records they cannot edit. It says they don't have permission. Obviously certain records have different permissions. How can I fix permissions at the record contact level? -- Dale Bechtel It Admin, Becica Associates LLC Mt. Laurel, Nj You can update the item level permissions using the pfdavadmin utility. "Dale Bechtel" <dbechtel@discussions.microsoft.com> wrote in message news:5BF6B1C5-CEA2-41C6-ACC2-0239A3AE3909@microsoft.com.....

Edit Links
When I go to edit links, I want to edit one link and then close it and then maybe edit another link. Excel continues to pop up a dialog box for me to edit other links. I have to click cancel on each one and then finally after a lot of time, it allows me to exit the edit-link dialog box. Why does it do this and what can I do to prevent it. There are indeed other links I need to change. I don't wish to do them all at the same time. ...

Access 2007 Reports Open/Edit Very Slowly
I recently updated to Access 2007 from 2003. Reports open much slower than they did in the past. In Design View, any attempt to Edit a report is extremely slow. Every action (move a field, resize a field, copy and paste) requires I click elsewhere on the report which gives me an hourglass for 7-10 seconds. When it disappears, I continuing editing and the next step produces the hourglass again. It is as if an AutoSave is occurring after each action. Is this common in 2007? I have Office 2007 SP2 installed. Any help to ease the frustration appreciated. ...

How do I make a document editable?
I have eleven pages of text that I've transferred over on a USB port, from Word 2003 to Word 2007. When I open it, I can't edit it at all. I can only read it. How can I make the entire document editable? What happens when you try? Are there any warning messages, or status bar messages? Has your Word 2007 trial expired? -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<&g...

Outlook Express wont download pop3 mail on specific PC
Hello there, I have the most unusual problem and unfortunely do not have much to go on as I do not have access to the specific PC. I was at a client site setting up there different Pop3 email accounts. BEfore my visit they had one PC which would pick up all the email for each different email box but I changed this around so that the different accounts would go to the different individuals PC's. However, on one of the PC's, when I enetered the exact same username and details, it would always say that an "unkown error" had occured and would let me send any emails although it ...

Export Outlook emails to Outlook Express #2
At Outlook Express, i exported all my emails to MS OUTLOOK Inbox. But now I want to export them back to Outlook Express but am unable to locate the selection of "Outlook Express" in the Export function of MS OUTLOOK. Appreciate your advice. Thanks "Kenny" <jkkit20@yahoo.com> wrote in message news:012c01c3614d$3bc6b480$a001280a@phx.gbl... > At Outlook Express, i exported all my emails to MS OUTLOOK > Inbox. But now I want to export them back to Outlook > Express but am unable to locate the selection of "Outlook > Express" in the Export functi...

Using VC .NET 2003 MFC Class wizard #2
No one ever answered this person's question, and I've yet to find anything remotley close on the net--I know this is not an uncommon situation--There is something seriously broke and/or underdocumented in the class wizard implementation in VC7. My situation is similar. I have a resource-only DLL (for localization) that has a bunch of dialog templates in it. I wish to use the class wizard to generate classes for those templates (they are actually property pages) and have those classes be generated in another project, which is a dialog-based application with no resources. Is there an...

Not receiving e-mails from outlook express
For some reason, I am not getting some of my e-mails. Friends say they are getting a message about being rejected. A site that used to send daily updates on job info is also not coming through. I still get some e-mails and even some junk mail. This is killing my job search. I've checked to see if they are blocked and they are not. I've tried to go back on my computer, to before this started, but it will not restore to that point. Please help? What's happened? How can I fix this. anonymous@discussions.microsoft.com <anonymous@discussions.microsoft.com> wrote: &...

To use xml files in vc++ resource editor..
Hi..please tell how to use xml files in vc++ resource editor so that we can access it from our application..Thanks What exactly you goin gto do with that XML file -- With Regards Alok Gupta Visit me at http://alok.bizhat.com "I think this will Help" "Mncyb2004" <Mncyb2004@discussions.microsoft.com> wrote in message news:FBC6EF97-1B6F-4012-9FAA-6B437EBC0AD8@microsoft.com... > Hi..please tell how to use xml files in vc++ resource editor so that we can > access it from our application..Thanks The question is a little vague. Do you...

OE express
cannot send out email..I do receive mail. err msg. says comcast is rejecting my username even though I can sign in? On Thu, 1 Jul 2010 16:47:53 -0700, "memoofran" <memoofran@comcast.net> wrote: > cannot send out email..I do receive mail. err msg. > says comcast is rejecting my username even though I can sign in? You undoubtedly have your smtp server set up wrong in Outlook Express. Contact Comcast for help in correcting it. -- Ken Blake, Microsoft MVP (Windows Desktop Experience) since 2003 Please Reply to the Newsgroup "memoofran&...

Error msg when restoring backed up mails to Outlook Express
I have been trying to restore my backed up mails to Outlook Express after recently reformatting my hard drive. I have followed the usual instructions which is open Outlook File>Import>Messages>Browse and then I specify the folder all the .dbx files are in and I get an error message saying 'No messages can be found in this folder or another application is running that has the required files. Please select another folder or try closing applications that may have files open' Any suggestions welcomed before I give myself concussion from headbutting the computer screen. A...

Unintended field "expression 1006" in the query grids
Hello, When I open my query, there is an unintended field "Expr 1006". I do not know why is this automatically created. Anyone tells me, why this happened. -- H. Frank Situmorang Hi Frank this usually means that you put the same field into the query twice. Jeanette Cunningham "Frank Situmorang" <hfsitumo2001@yahoo.com> wrote in message news:2CF86F30-0E4D-499B-9FE0-D62BF450BC57@microsoft.com... > Hello, > > When I open my query, there is an unintended field "Expr 1006". I do not > know why is this automatically created. Anyone tells me, w...

Sorting based on an expression
Hi, I have a report set up where I've set the grouping and sorting to: Team Name Title Full Name Basically, sorts the report by team, then puts people with the same titles together in alphabetical order. I would like to now keep the same idea, but now sort the people with the same titles in descending order based on the # of hours they've worked. I only show the footer of "Full Name" because I have it sum up data for a period of time and I don't want it to show the individual monthly data. So the value I want to sort is an expression called [Text152] -- it'...

how do I edit gridlines in one row
I want to create chart heading. When doing this, I need to erese the column sperators in the first two rows, only. I tried it, in "format cells," but to no avail. Is there some way to do this or do I need to create my accounting chart, then edit it in Powerpoint? Hi unless you've selected otherwise gridlines don't print (file / page setup / sheet tab) ... however you CAN merge the cells - select them and choose format / cells / alignment tab - merge cells but a better option (merged cells can cause you problems if you ever want to sort or filter) would be to sele...

Contstant Credential Prompt
I've run into an issue with Outlook 2007 constantly asking for user name and password on Windows 7 clients connected to a SBS 2008 network. The type of password prompt that comes up is the same that you get when connecting from outside the lan using RPC over HTTP - the window indicates that the connection is being made to "remote.xxxx.xxx" This problem occurs when the windows 7 clients are on the LAN. Even though the prompts come up repeatedly, outlook still connects and email flows fine. When the computers were first setup a couple of weeks ago, there were no ...

outlook express reply problem
on one of my machines (xp media) OE hangs and times out when i reply to HTML messages. the message will send if i convert it to plain text. i do not have this problem if I originate (rather than reply to) an html message.. any ideas? thanks for the help marty mdd614@gmail.com wrote: > on one of my machines (xp media) OE hangs and times out when i reply > to HTML messages. the message will send if i convert it to plain > text. i do not have this problem if I originate (rather than reply > to) an html message.. any ideas? Actually, Outlook Express questions should be addresse...

How to trap file reading and writing in Shared Folder over a Network in my VC program?
Hi, How to trap file reading and writing in Shared Folder over a Network for Workgroups in Windows? Thanks. ...