|
I would not create objects everywhere you need something, it may delay your application. I speak from a bad experience: I was making my thesis as my tutor said, bringing everywhere the objects, working with them and updating and it was damm slow. After I end my studies, I totally remade the program working with a centralized document/data module and passing references/pointers, and speed went about 7-8 times faster.
For some times is ok, but if you are planning to do it with lots of objects or with very big objects... I would make it not creating new objects, but telling where the object is to be edited.
BTW, to the intial question, If you are working with references as input parameter in a function you can give a pointer to that parameter as well.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Actually I feel this bad thing. Working with large number of object, alway a mess up with coding. Anyway thanks for your advice.
I appreciate your help all the time...
Eranga
|
|
|
|
|
If you are working with MFC I recommend you to use the functionality of Doc/View. If not... make your own class "DataStore".
To use the Doc/View from abstract classes derived from CObject you can use the trick I made. Declare a CMyDoc* m_pDoc in the stdafx.cpp. Then in your main view use the OnInitialUpdate () to make:
extern CMyDoc* m_pDoc;
m_pDoc = GetDocument ();
ASSERT (m_pDoc);
and you already have a pointer to go to your document / datastore everywhere in your application. Don't matter if is a view, a dialog or an abstract class.
And about the big objects, take a look into the commentars that I wrote in my article[^], I explain about the data hierarchie I used. Althought it can seem a chaos, with references and pointers was not so difficult and, as I already said, the differrence in speed is quite notable.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I have a sample project. I need to study this project and I am not able to view the resources of this project. I have the file *.rc of this project too. please tell me how can I view all the resources used by this project ?
keyto_me@yahoo.com
|
|
|
|
|
When you open your project with Visual studio you can use of Resource View for see objects.
|
|
|
|
|
On the Right pane(Explorer), Right Click on the Project workspace name and Select 'Add Files to the Project' option. Then in the dialog, select the required .rc file. By doing so the resource files should get displayed in the tab.
Priya Sundar
|
|
|
|
|
|
dear all
my issue is below:
:\MyProject\MyProjectDlg.cpp(8) : fatal error C1083: Cannot open include file: '..\MyLibrary\MyLibraryst.h': No such file or directory
Error executing cl.exe.
MyProject.exe - 1 error(s), 0 warning(s)
how to solve it?
thanks a lot
|
|
|
|
|
You haven't such file inside that directory or you haven't the directory itself.
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.
|
|
|
|
|
but actually i have already included such file.
|
|
|
|
|
Yes, but...
If the file is not in the correct path... Error.
If the file/path is not correctly written... Error.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Do you have this MyLibraryst.h ?
|
|
|
|
|
yes, i have this MyProject.h
|
|
|
|
|
actually MyLibrary is static library what i added in project name -Myproject .....here
|
|
|
|
|
have you included the *.lib to the project?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Also make sure that particular file is not being used by any other application which is running while you are compiling this project.
Priya Sundar
|
|
|
|
|
Are you using precompiled headers? Is your precompiled header including "MyLibraryst.h"? You might need to make the path relative to stdafx.h instead of your .cpp file.
Florin Crişan
|
|
|
|
|
Hello!
I have an mfc view changing application with about 150 Views. Compile Time is about 45 Minutes using Visual Studio 2005 with a 3.06 HT Intel with 1 GB Ram.
Does anyone know what can speed up this procedure best. More CPUs, more powerful CPU or more ram or any other suggestions?
|
|
|
|
|
It must be a beast. I used to work on an App of about that magnitude (250 dialogs a dozen views, multiple scripting engines etc) and it took 45 mins to build on a Pentium 90. Have you considered dividing up the application so you don't have to rebuild all of it so often. I think this is going to save you more time than throwing hardware at the problem. Automated builds over night are good if you can arrange for them but development builds to test changes should ideally be restriced to the changed modules which in a good architecture will be only a subset of the system. As a very rough rule of thumb is any of your components are 1-2MB in Release builds ~4MB in Debug builds then they really want subdividing.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Perhaps the architecture isn't the best, but the main problem is a "global" Header file with constants used by more projects that causes a recompile if changed.
So we think about using more powerful machine to make compile times faster.
|
|
|
|
|
MarcoNedwig wrote: the main problem is a "global" Header file
You *do* use "precompiled headers", do you?
And you don't change this constants often and build only to update them?
If you do, you would be better off with reading them from a file at runtime.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I agree with Mathew,
it should be easier to divide into modules, than change hardware. Other thing is when the final result works slow in the computer, but in development...
On the other hand, it may not be easy to divide the project, good luck.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
I agree that breaking up into modules (libraries/DLLs) would be the best thing - but that's not straightforward, you have to be very careful with change management, header inclusion etc.
You still need a full rebuild regulary, so here are som tips. Don'texpect to much, though, shaving off 50% off the compile time is highly unlikely.
In my experience, the VS2005 C++ compiler is mostly CPU limited, so there's not much you can do besides go to a fatter CPU. However, for such a large project, 1G is short. Add more, it will help even if it is just used for disk cache. (check swap file use during build - if it's heavy, you can expect huge gains)
Defrag the VS2005 drive and the drive you build to.
Check if CPU really clogs during build (it might limit at 50%, due to HT). I expect it to do so, but if it doesn't you may be limited by disk speed. (Which is actually be good news, because there's quite some room for improvement. VC6 building to a RAM disk would reduce build times by about 40%. However, comparing a VS2005 build to a good single samsung disk vs. a WD Raptor RAID did not show any difference on my dev system)
Also, IIRC VS2005 uses multiple CPU's only for separat projects that can be built independently - that might be the main reason for splitting up the code base.
In my experience, turning OFF hyperthreading for a single-CPU load is actually faster (less than a percent, though). When building in parallel, you should definitely turn off HT, as you will be trashing cache like mad.
Make sure you build with sensible compiler settings:
if "generating browse files" still works the same way it did, turn it off. Check your precompiled header settings - use a dedicated stdafx.h/stdafx.cpp (do not use automatic) play around with which headers actually included there.
Release builds with optimization turned on can take much longer (and needs much more CPU + probably RAM)
If you want to build a new system: go for raw CPU power and memory throughput, have one disk for the OS, and a secondary for builds. I'm partial to AMD Opteron - though make sure you jump on the new socket.
Always measure, though!
Oh.. and tell me what you tried, and if it helped
Another idea: try turning off "write through" for the disk that receives temporary + output files. The problem is, you definitely don't want that for the drive containing the source code, so you will have to adjust some settings.
|
|
|
|
|
I am a C# developer, recently I got to do with a VC++ 5.0 project, I stuck up with the following situation,
Saving a string(CString) to file which should be saved as UTF-8 encoded.
<br />
void CPrintMakerDlg::SaveHTML(LPCSTR fileName,CString fileContent)<br />
{<br />
ofstream iofile;<br />
try<br />
{<br />
LPCSTR str = fileContent.GetBuffer(fileContent.GetLength());<br />
iofile.open(fileName, ios::in | ios::trunc |ios::binary );<br />
iofile.write(str,fileContent.GetLength()); <br />
}<br />
catch(...)<br />
{<br />
AfxMessageBox("The problem is on saving file");<br />
}<br />
iofile.close(); <br />
}<br />
I heard the CString will be using internally multi-byte character, So I expecting the file format also should be the UTF8 format but its saving as a ASCII.
Thanks,
Vythees
|
|
|
|
|
vytheeswaran wrote: I heard the CString will be using internally multi-byte character, So I expecting the file format also should be the UTF8 format
MBCS and UTF-8 are two different beasts. If your machine is using a loaded code page like Latin-1, I don't believe MBCS will contain any lead bytes that would lead to a double byte sequence anyway. The other western encodings might have them but I've never seen one in action in the US.
vytheeswaran wrote: but its saving as a ASCII
Are you sure it's limiting output to ASCII. It's more likely what some refer to as ANSI. Try outputing a character above index 127. Did the output resemble what MSDN lists for ANSI?
Character sets[^]
Transformation formats[^]
UTF[^]
|
|
|
|