Am i defining this struct wrong?
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
Delete the struct name in the first line : typedef struct { . . So far ... RockNix/// ------------------------------------ www.klangwerker.de Need some articles about Threading, Subclassing, Double Buffering ? Go for it ... Look out for free Win32 Serial Communication Module for VC++ or Borland C++ Builder Visit us on www.klangwerker.de ------------------------------------
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
I think what you wrote is correct. I used to code NI's drivers with many of such struct typedefs. And 3 minutes ago I copied your struct and pasted onto a console project and a MFC project, both of them compiled without an error! Maybe you post the entire build log, and we could find out what happened..... Maxwell Chen No code is good code.
-
I think what you wrote is correct. I used to code NI's drivers with many of such struct typedefs. And 3 minutes ago I copied your struct and pasted onto a console project and a MFC project, both of them compiled without an error! Maybe you post the entire build log, and we could find out what happened..... Maxwell Chen No code is good code.
-
You may rebuild all again, and copy the content in the Build tab of the Output window. Or you may copy what in the .plg file.... Maxwell Chen No code is good code.
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
Anonymous wrote: when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" From the looks of it, it seems that _ID3Info is somehow aready defined. It could be that: 1. You have a struct of that name defined somewhere else 2. Perhaps you don't have "include guards" in the header file that defines the struct, and it is getting pulled in twice. I always do something like this to ensure that #2 does not happen: #ifndef _whatever_your_h_file_name_happens_to_be_ #define _whatever_your_h_file_name_happens_to_be_ (code of the include file goes here) #endif No generalization is 100% true. Not even this one.
-
Delete the struct name in the first line : typedef struct { . . So far ... RockNix/// ------------------------------------ www.klangwerker.de Need some articles about Threading, Subclassing, Double Buffering ? Go for it ... Look out for free Win32 Serial Communication Module for VC++ or Borland C++ Builder Visit us on www.klangwerker.de ------------------------------------
The name after the struct is a "tag". The posters problem is elsewhere. Cheers, Tom Archer Author, Inside C# A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
Like Navin, your struct compiles fine in my code. I think if you follow his advice you'll find the source of your problem. Cheers, Tom Archer Author, Inside C# A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.
-
Anonymous wrote: when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" From the looks of it, it seems that _ID3Info is somehow aready defined. It could be that: 1. You have a struct of that name defined somewhere else 2. Perhaps you don't have "include guards" in the header file that defines the struct, and it is getting pulled in twice. I always do something like this to ensure that #2 does not happen: #ifndef _whatever_your_h_file_name_happens_to_be_ #define _whatever_your_h_file_name_happens_to_be_ (code of the include file goes here) #endif No generalization is 100% true. Not even this one.
Navin wrote: #ifndef _whatever_your_h_file_name_happens_to_be_ #define _whatever_your_h_file_name_happens_to_be_ (code of the include file goes here) #endif You could also use:
#pragma once
instead of the above ... however the above woudl be the more standard way of doing things :-D
:~ (-_-) :~
-
typedef struct _ID3Info
{
char Title[33];
char Artist[33];
char Album[33];
char Year[5];
char Genre;
char Comment[33];
} ID3Info, *pID3Info;when i define it that way Visual C++ compiler says: "error C2011: '_ID3Info' : 'struct' type redefinition" what am i doing wrong? Thanks
Navin wrote: #ifndef _whatever_your_h_file_name_happens_to_be_ #define _whatever_your_h_file_name_happens_to_be_ (code of the include file goes here) #endif You could also use:
#pragma once
instead of the above ... however the above woudl be the more standard way of doing things :-D
:~ (-_-) :~
-
Navin wrote: #ifndef _whatever_your_h_file_name_happens_to_be_ #define _whatever_your_h_file_name_happens_to_be_ (code of the include file goes here) #endif You could also use:
#pragma once
instead of the above ... however the above woudl be the more standard way of doing things :-D
:~ (-_-) :~
-
Brian Delahunty wrote: #pragma once Yes, my way would be more "standard", but yours is prettier. :-D No generalization is 100% true. Not even this one.
Navin wrote: Yes, my way would be more "standard", but yours is prettier. Thanks ;)
:~ (-_-) :~