|
Wo, that's fabulous.Thanks a lot.
|
|
|
|
|
I get compilation errors while using multiple header inclusion in Win32 console application. At the moment I use Visual Studio 2008.
EDCA.cpp:
#pragma once
#include "stdafx.h"
#include "mac.h"
#include "globals.h"
void main()
{
StaT as;
Mac asdf;
asdf.accesspoint = 0;
}
mac.h:
#pragma once
#ifndef mac_h
#define mac_h
#include "globals.h"
#define AC 4
enum StaT{
AP,
STA,
REP
};
class Mac{
public:
StaT type;
Mac () {}
};
#endif
globals.h:
#pragma once
#ifndef globals_h
#define globals_h
#include "mac.h"
extern const double SIFS;
extern const double SLOT;
#define AC 4 //number of access categories
extern int staNr;
extern Mac *sta;
StaT fg;
#endif
It doesn't matter whether I use #pragma once, #ifndef #define or both of them. It always results in such errors:
1>d:\studia\mgr\program\edca\edca\globals.h(14) : error C2143: syntax error : missing ';' before '*'
1>d:\studia\mgr\program\edca\edca\globals.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\globals.h(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\globals.h(16) : error C2146: syntax error : missing ';' before identifier 'fg'
1>d:\studia\mgr\program\edca\edca\globals.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\globals.h(16) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\mac.h(17) : error C2146: syntax error : missing ';' before identifier 'type'
1>d:\studia\mgr\program\edca\edca\mac.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\mac.h(17) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\studia\mgr\program\edca\edca\edca.cpp(12) : error C2146: syntax error : missing ';' before identifier 'as'
1>d:\studia\mgr\program\edca\edca\edca.cpp(12) : error C2065: 'as' : undeclared identifier
1>d:\studia\mgr\program\edca\edca\edca.cpp(13) : error C2146: syntax error : missing ';' before identifier 'asdf'
1>d:\studia\mgr\program\edca\edca\edca.cpp(13) : error C2065: 'asdf' : undeclared identifier
1>d:\studia\mgr\program\edca\edca\edca.cpp(14) : error C2065: 'asdf' : undeclared identifier
1>d:\studia\mgr\program\edca\edca\edca.cpp(14) : error C2228: left of '.accesspoint' must have class/struct/union
1> type is ''unknown-type''
I always used #ifndef #define directives when I wrote a code in VS 2005 on Windows XP and it worked well. When I try to open some past projects in VS 2005 on my new computer with Windows Vista, I get similar errors. Can anyone explain it to me?
modified on Saturday, April 18, 2009 4:30 PM
|
|
|
|
|
Hi,
always try and solve the first error message first.
It indicates a problem in "extern Mac *sta;" and that is because Mac is not yet defined.
Which is caused by mac.h (which contains the Mac definition) including globals.h before Mac got defined.
Solution candidate 1: remove the include global.h from mac.h (depends on possible unshown content)
Soultion candidate 2: inside mac.h define Mac before including global.h
|
|
|
|
|
Mac is not yet defined, because "Mac.h" was not included in global.h, although I wrote #include "mac.h".
I can't uinderstand why it happens. Why do directives #ifndef, #define stop compiler from including this header. When I delete these directives (#pragma once too) I get multiple inclusion error.
Your propositions are not solutions but problem avoidance. I can't use any of them.
|
|
|
|
|
mass85 wrote: Mac is not yet defined, because "Mac.h" was not included in global.h, although I wrote #include "mac.h".
I can't uinderstand why it happens. Why do directives #ifndef, #define stop compiler from including this header. When I delete these directives (#pragma once too) I get multiple inclusion error.
You need to look at it from the source file (ecda.cpp).
You first include mac.h. The first thing you do in mac.h is to include globals.h. The first thing you do in globals.h is to include mac.h...but mac.h is protected from multiple inclusions. That means that the entirety of globals.h is seen BEFORE the content of mac.h
What I'd do, if I were you, is to remove the #include "globals.h" from mac.h - if you look at it, mac.h has no dependency on anything in globals.h
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
That's a good explanation. Thx.
This code is just the beginning of my project. In the future I will need an access to global objects from Mac class. In fact I will need it in functions of Mac class, so perhaps including globals.h in mac.cpp will be enough and I will be able to delete #include "global.h" from mac.h. In that case these errors won't occur, am I right?
|
|
|
|
|
That's quite correct.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Sure. You know best. Who was having a problem?
|
|
|
|
|
I guess you didn't understand me. Whatever.
|
|
|
|
|
|
Please post your question to the managed C++/CLI [^] forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
hi
i need a simple class which implements a matrix of mxn elements of complex numbers. i need this class to be a complete one. eg. supports inverse and multiplication to another matrix. i don't need it to be a template one. components are always complex numbers. but if it be, it would be more general.
thx
|
|
|
|
|
Well, you are a software developer, arent you? Code it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yeah, i am, but indeed i've forgotten some mathematical bases!
for example, i've no idea about how to invert a matrix!
|
|
|
|
|
There's the oldie-goldie "Numerical Recipes in C" [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
ilostmyid2 wrote: i like to upload it like himself, but i don't know how.
Do you possibly mean that you want to write an article about? Write it, it would be welcome, I suppose.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
the resulting code is a matrix class which holds and may work with complex numbers instead of real numbers, as i said b4.
it's a good idea that others may have and use it too and also warn me about some mistakes if i had any. although i've tried not to change any part unless it's necessary, it's not unlikely that i've done mistakes or even the mister allen.
i like to upload it (the code), but i still don't know how!
regards
|
|
|
|
|
ilostmyid2 wrote: i like to upload it (the code), but i still don't know how!
Test well you code (you may possibly contact the author of the original article) and then write an article about (see 'Article->Submit An Article' menu item).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
ilostmyid2 wrote: i don't need it to be a template one
Shame that, 'cause otherwise I'd suggest std::complex[^] + Boost's UBLAS classes[^].
Still, I'm sure you've got a good reason not to use templates.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i've said that i don't NEED it to use a template type for the elements, that's if it's not template, it's also acceptable if it uses complex for the elements.
i knew the complex class and had used it.
i couldn't find any code in the other link for inverting a matrix. i've not much time in understanding and remembering the basic concepts and writing the code based on them. i need a ready-to-use class.
modified on Saturday, April 18, 2009 10:47 PM
|
|
|
|
|
Google[^] is your friend[^]?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How to create no active child window in MDI?
I create a child window in this way:
pWndTemplate->OpenDocumentFile(NULL);
How can I catch ShowWindow() to put SW_SHOWNOACTIVATE parameter? Is this a solution?
modified on Saturday, April 18, 2009 3:22 PM
|
|
|
|
|
I found one...
void CMyChildWndFrame::ActivateFrame(int nCmdShow)
{
nCmdShow = SW_SHOWNOACTIVATE;
CMDIChildWnd::ActivateFrame(nCmdShow);
}
|
|
|
|
|
Hi!
I have build a TCP DLL, and now I want to use it.
I have created all the typedefs for the function inside the DLL and now I want to use them with extern.
I added the DLL to my linker as an input but I get errors:
This is the code:
extern TCPLIB_RETRIEVE_N_BYTES_PTR tcplib_retrieve_n_bytes_ptr;
These are the errors:
Error 1 error C2146: syntax error : missing ';' before identifier 'tcplib_retrieve_n_bytes_ptr' d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\my_documents\visual studio 2008\projects\servertest\servertest\servertest.cpp 6 ServerTest
What am I doing wrong here?
Is there another place to define the DLL in my project?
Thanks guys
modified on Saturday, April 18, 2009 12:56 PM
|
|
|
|