|
zqueezy wrote: I have a file called like ProjectCPrivate.h that I include from each header file from within project C
Sounds like you're coupling the external interface of each 'Project C' to the internal interface - that's probably something to minimise, otherwise changes to that internal interface will require rebuilding of the whole system that's upstream of it.
That should help when doing incremental builds. As for full builds...well, I've never found that the number of include files is much of a problem - it's the total amount of source code needing to be built...Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I have a struct similar to the following:
template<int i>
struct foo {
public:
static const int a;
static const int b;
};
template<>
const int foo<3>::a = 1;
template<>
const int foo<5>::a = 2;
template<int i>
const int foo<i>::b = 3 * foo<i>::a; Then, I attempted to execute the following:
#include <iostream>
#include "foo.h"
using namespace std;
int main() {
cout << foo<3>::b << endl << foo<5>::b << endl;
return 0;
} The first time I ran this code, the code produced the result b=0 for both template instantiations, but at the time I was declaring static member b prior to a. Next, I switched the order of declaration thinking that perhaps static members are initialized in the order they are declared, just like instance members. Again, the code produced 0 for the value of static member b in both template instantiations. Then, I added a cout statement prior to the one presented in the code above to print the value of a when the template parameter i=3. This time, the output was correct and gave b=3 when i=3 and b=6 when i=5. Since then, I have been unable to get my code to break, but think there is some static initialization problem that could be lurking. Does anyone know why this happened, and how I can address it?
I am also wondering how I can move the static member initialization code out of the header file where class foo is declared. I was able to move the initialization of static member a to whatever compilation unit I wanted, but when I moved initialization of b to the other compilation unit I started receiving unresolved external linker errors. Thanks,Sounds like somebody's got a case of the Mondays
-Jeff
modified on Thursday, February 11, 2010 3:50 PM
|
|
|
|
|
What compiler are you using? When using VS2008, your initial code works fine...I suspect VC++ compiler issues - there are lots of thm with regard to templates... Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
I am using Visual Studio 2008. I think I found my error... when I move the template-specialized definition of foo::a to a different compilation unit, I get unexpected results. Some of my data members declared exactly like foo::b are populated with the correct values dependent on foo::a, while others are being incorrectly initialized to 0. I guess I just don't know the rules for static initialization. Is it performed in the order of declaration, order of definition, or in the order of first access? Thanks, Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Templates complicate the rules, I suspect…
Not sure - the C++ Standard is the ultimate arbiter.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Skippums wrote: when I move the template-specialized definition of foo::a to a different compilation unit, I get unexpected results
Beware of the fact that compiler may remove code that's not referenced, as linker may skip linking of non called modules.
If you define the static-s in a separate translation unit, make sure that there is some code in that translation unit that is called from outside, or the linker may skip the module.
A typical way is to define a void init_mymodule(){}
or a class raii_module_loader { ctor; dtor; }; , with ctor and dtor defined in the module (not the header) and make sure at global level in the main() definition file, the function is called, or the raii_module_loader is globally instantiated.
This force the module code to be called and hence the module to be linked.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Got it... apparently it is dependent on the order of declaration, just like non-static members. Thanks, Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
tell me proper way to add an item to ListCtrl.
Here is my code:-
#define WM_MYMESSAGE (WM_USER+1)
-------------------------------------------------------
class CMyThread : public CWinThread
{
DECLARE_DYNCREATE(CMyThread)
.
.
.
public:
unsigned int f0ll, f1ll, f2ll, f3ll;
unsigned int f0ul, f1ul, f2ul, f3ul;
public:
afx_msg void MyMessageHandler(WPARAM, LPARAM);
-------------------------------------------------------
.
.
.
afx_msg void CMyThread::MyMessageHandler(WPARAM, LPARAM)
{
}
BEGIN_MESSAGE_MAP(CMyThread, CWinThread)
ON_THREAD_MESSAGE(WM_MYMESSAGE, MyMessageHandler)
END_MESSAGE_MAP()
-------------------------------------------------------
.
.
.
void CIPMDlg::OnBnClickedBrefreshdevices()
{
.
.
.
pRefreshThread = AfxBeginThread(RUNTIME_CLASS(CMyThread));
pRefreshThread->PostThreadMessage(WM_MYMESSAGE, 0, 0);
} Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
If "MyThread" is not the thread that owns the ListCtrl, then you will have problems.
You must add items to the ListCtrl only from the thread that created the ListCtrl.
|
|
|
|
|
CIPMDlg class created the ListCtrl
should I post a message back to the main thread's message pump to add item to ListCtrlFuture Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Manmohan29 wrote: should I post a message back to the main thread's message pump to add item to ListCtrl
Yes."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I need to find out (in a release version) how much memory has been allocated after loading (a large) object - the object itself is loaded by a DLL (if that's relevant). I am looking at GlobalMemoryStatus but not sure sure which properties I should use to get accurate information...
Help welcome!
Jerry
|
|
|
|
|
Hi,
I am starting a project where in I have a dual monitor setup for shown objects.My project involves showing squares, circles, lines on the screen. I use the primary monitor to control the attributes and the second monitor solely for display. I have issues setting up these two windows/frames; one in each monitor using MFC app wizard. I am at loss as to which model I should use: SDI or MDI. Any ideas, pointers to existing projects, directions are more than welcome..
rgds,
-K
|
|
|
|
|
As a final user, in general I hate when an application want to decide itself how to set the the spaces into my desktop.
Unless you are in a very captive environment (PC running your application only, may be on a synoptic etc.), the best way is to operate on two different frames and let the user to decide where those frames must go and how they have to be sized.
What you can do is save the frames positions (may be in registry, or in a "state file", into the user data directory) so that they can be placed the same among different invocations.
Using SDI or MDI is than much more a matter of the complexity of the frames content, than the fact there are two of them.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
What Visual Studio version are you using?
I did some multi-monitor work in VS6 in C, at an SDK level (i.e. not using MFC.)
If you don't find a solution, let me know and I will dig out some brute-force code I used to detect the number of monitors and position windows on the different monitors. It's not elegant but it works. As I said, it would be straight C stuff, not MFC - I never got into that complicated stuff!
|
|
|
|
|
Hello,
I need to call some how non-exported functions of a DLL.All non exported functions don't have any table at all to which some looks up and find entries.
If some how we track the exact place where non exported function lies inside PE, copying or duplicating their entries in export table of that DLL of whom non exported functions I am interested in to call (until I need those non exported functions) and releasing those after done..
Any suggestions or recommendations?
Regards
Muhammad Usman Khalil
|
|
|
|
|
If they are not exported then I do not think there is any way you can find them. Exported functions are only 'visible' because the LIB processor puts information in the DLL to make them so. Non-exported functions do not have this extra information so there is no way you can find them.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Can you try LoadLibrary and GetProcAddress?
-Saurabh
|
|
|
|
|
Hi there,
I have given this application that includes a dll and ini file that has to be in system32 folder in Windows machine and another VB application that uses the dll and ini to display the activities of the application. there is also another application that is Linux based and runs on Ubuntu to have just one server I want to install and run the application on the Linux based server by using Vine virtual machine. My problem is that I am not sure how I can change the C++ application code to read the dll and ini files from another folder (i.e. C:\Application) rather than Windows32 folder. Here is what the application have in config class (of course the original programmer didn't provide any comments or documents and the application is more than 15000 lines of code):
.h:
#ifndef __CfgClass_H__
#define __CfgClass_H__
#include <windows.h>
#include <windowsx>
#include "stdafx.h"
.cpp:
memset( CfgFilePath, '\0', MAX_PATH );
if( GetSystemDirectory( tmpFile, MAX_PATH )== 0 )
{
return;
}
wsprintf( CfgFilePath, "%s\\Application.ini", tmpFile );
Any help will be appreciated.
Regards,
Chan
|
|
|
|
|
Take this code:
wsprintf( CfgFilePath, "%s\\Application.ini", tmpFile );
and change it to:
wsprintf( CfgFilePath, "%s\\Application.ini", "<code>C:\\NewPath</code>");
|
|
|
|
|
|
Hi
I Execute the following sql statement successfully for a Database connected to my CDaoDatabse Object.
CREATE TABLE Scores (
StudentCode Text(9) NOT NULL,
CourseCode Text(7) NOT NULL,
SemesterCode Text(3) NOT NULL,
Score Double
);
CREATE TABLE Courses (
CourseCode Text(7) NOT NULL,
CourseName Memo NOT NULL,
CourseTypeID Integer NOT NULL,
CourseCategoryID Integer NOT NULL
);
ALTER TABLE Scores ADD CONSTRAINT PK_Grades
PRIMARY KEY (StudentCode, CourseCode, SemesterCode);
ALTER TABLE Courses ADD CONSTRAINT PK_Courses
PRIMARY KEY (CourseCode);
ALTER TABLE Courses
ADD CONSTRAINT UQ_Courses_CourseCode UNIQUE (CourseCode);
But Finally I Get Error message(Syntax error in CONSTRAINT clause.) on this satement that is at the end of my execution list.
ALTER TABLE Scores ADD CONSTRAINT FK_Scores_Courses
FOREIGN KEY (CourseCode) REFERENCES Courses (CourseCode)
ON UPDATE CASCADE;
And I don't know Why
|
|
|
|
|
I'm trying to the the SetElementProperty with the CDHtmlDialog, but can't figure out how to get the DISPID of the property to set. Can anyone point me in the right direction?
CDHtmlDialog seems pretty impressive, but I can't find a lot of coding examples using it.
Thanks much - Kevin
|
|
|
|
|
Hi All.
I can copy a text and then can programatically paste the same on top of any text editor.
Now, what I want to do is...
If I have a file in the clipboard (Ctrl+C) and then want to paste the same onto any open folder, then How can I do that?
I tried to send Ctrl+V to the window but I am unable to get the result.
Can someone please provide me some pointers, so that move ahead?
Please let me know, in case any clarification required.
Thanks
PanB
|
|
|
|