|
include <moo.h>
class loo
{
private:
moo* poo;
}
moo is a complicated structure from a third party library.
I want to make sure that any project with a class derived from loo
will not need to add the include paths for moo.h and all associated
headers in the project as it can get quite compilacated.
if moo was a class i would normaly just create a forward declaration of
class moo; in the loo header file then include the moo.h header file in the
implementation file for loo.
It won't let me do this for a structure though.
Does anyone have any ideas as to how i can solve this?
Currently my only idea is to use void* and cast then to the required type
whenver i need to use them in the implementation file!!
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Jawache wrote:
It won't let me do this for a structure though.
Really? Forward declaration for structs works for me. Can you post the typedef from moo.h?
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
These are the first two error messages i get...
1> e:\jawache\dev\src\jdv\pyfile.h(16) : error C2371: 'PyObject' : redefinition; different basic types
// This is my forward declaration in my pyfile.h
struct PyObject;
2> e:\python-2.2.1\include\object.h(82) : see declaration of 'PyObject'
// This is the declaration of PyObject in object.h
typedef struct _object {
PyObject_HEAD
} PyObject;
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Use '_object' in forward declaration and in member definition:
struct _object;
class DoopaZoopa
{
...
_object *p;
};
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Excellent,
Thanks that got it.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Er, anyone has a short and simple email validation code for C++? Need to look up the domain or anything. Just ensure that the text given would qualify as an email address.
Nish
p.s. Kindly don't answer me with "You can do that with one line of reg exps" cause I don't know jack about reg exps
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
|
Nish bangs his head repeatedly against the monitor!!! Not satisfied with that he lifts up the heavy tower and drops it on his feet! Satisfied with his thoroughly masochistic exercise he sits back and continues to stare incredulously at Tomasz’s reply
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Ok, when the pain is over, take a look here[^] and here[^]
int x=1, y=5;
x^=y^=x^=y;
<a href="http://www.codeproject.com/tips/StupidXORTrick.asp" target="_blank">ClickHereForHelp();</a>
|
|
|
|
|
Don't tell me an advanced programmer like you can't parse a string like mail@mail.org
For some reason I can't believe that
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have the following code in my program (written in C not C++):
typedef struct
{
char *(*errors)[];
}ERROR_LIST;
char *errors[]=
{
"An error",
"Another error",
};
ERROR_LIST err_list={&errors};
The declaration gives the following compiler error on the line indicated.
warning C4048: different array subscripts : 'char *(*)[]' and 'char *(*__w64 )[2]'
I am using the /w64 compiler switch intentionally to maintain 64bit compatibility.
Could somebody please give me a clue how to resolve this warning as its driving me nuts!
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
And like this ? :
<br />
typedef struct {<br />
char *(*errors)[];<br />
} ERROR_LIST;<br />
<br />
char *errors[];<br />
ERROR_LIST err_list={&errors};<br />
char *errors[]={"An error","Another error",};<br />
|
|
|
|
|
That works but can you explain why?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
I'm not a guru but I suppose the the compiler interpret (well a compiler does'nt interpret code, but...) :
char *str[] = {"one", "two"};
as
char *str[2] = {"one", "two"};
I think (not shure) that your code might compile in old C but not in C++ (new behaviour).
|
|
|
|
|
I have an dll that write with MC++.How can I import it to my project?When I add #import line in my stdafx.h I got an error that it can't open this library file.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
r u given the path for #import directive?
other wise u can put the dll in your working directory
anju
|
|
|
|
|
|
Would you please give me more details Nish?How can I use it?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Okay here goes :-
- First use tlbexp on your mc++ dll to get the tlb file :-
tlbexp mcpp.dll /out:mcppdll.tlb
- Now register the dll using regasm
- Now simply
#import mcpp.tlb in your unmanaged C++ code and use it just as you'd use a normal COM dll
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Thank you Nish.
Does use it in this way reduce speed or performance in comparision to using unmanaged c++?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
Thanks Nish,I found my problem
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I think I forget my COM skills Nish,I have a problem with it.I register and import them into my project.I have some class in my dll.I can see them in my editor(CTRL+space) but when I compile them it gives me an error that they are undeclare identifier.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
How can i set a new icon in the toolbar of my MFC program at run-time ?
How to link the windows message sent when the user click the new button with a predefined function ?
Thanks !
|
|
|
|
|
I think you could just create the toolbar as normal.
Link the message map handlers as you would normaly.
But then set the state of the button to TBSTATE_HIDDEN with the SetState command.
When you want to *add* it just set the state to Not HIDDEN.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|