|
i have just finished compiling my application and everything is in order, but when i run it to test the different features, there is a runtime error...and it deals with access violation, hence a pointer issue. i need help fixing this and following is the call stack:
int wNode::getId() <br />
{<br />
return id;<br />
}
-----
int* workflow::getIDArray()<br />
{ <br />
int total = numNodes; <br />
int i = 0;<br />
int* IDs = new int[total];<br />
wNode* temp = first;<br />
while (temp != NULL) {<br />
IDs[i] = temp->getId();<br />
if (temp->getHasLeft()) {<br />
IDs[i+1] = temp->getLeft()->getId();<br />
i++;<br />
}<br />
temp = temp->getNext();<br />
i++;<br />
}<br />
return IDs;<br />
}
-----
<br />
int* wf_ids = dg_scenario::dg_workflow->getIDArray();<br />
any help would be greatly appreciated..i am new to c++ and thus am having a hard time tracing my steps and finding which line has the faulty pointer issue.
NOTE: the application has no compiler errors.
--
dg
|
|
|
|
|
You've left too much out to give you any real help. What is numNodes? Exactly which line in getIDArray caused the access violation? You should run your app under the debugger, put a breakpoint on the first line in getIDArray , and step through it, looking at variables.
p.s. It's much easier to read code if you use the "pre" tags.
|
|
|
|
|
numNodes is a data member in the workflow class that keeps a count of the number of nodes in the workflow.
here is the complete runtime error:
First-chance exception at 0x004fd341 in spring.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
Unhandled exception at 0x004fd341 in spring.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.
the line it takes me to is:
int wNode::getId()
{
return id; <<<<----------------that one
}
is there anything else you need??
i tried putting a breakpoint in the first line of getIDArray but what do you mean "step through it"?
--
dg
|
|
|
|
|
Typicaqlly Access violation reading location 0xcdcdcdcd means you read Uninitialised Data. This is how the Compiler (Debug Version) Padds Newly Allocated Data.
LateNightsInNewry
|
|
|
|
|
I give the following advice about once a month (recently every few days); it often helps me track down the nastier heap errors:
Try enabling the page heap[^] for your process. Follow these steps:
1. Download and install WinDBG[^].
2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”.
3. Select the “Image File” tab.
4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path.
5. Tick the following:
- “Enable page heap”
- “Enable heap tail checking”
- “Enable heap free checking”
- “Enable heap parameter checking”
- “Enable heap validation on call”
- “Create user mode stack trace database”
6. Press “Apply”.
7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated.
8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled.
Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.
Steve
|
|
|
|
|
Question
What is the reason for those nasty heap problems. I Still use VCPP5.00 and have had very very few of these problems. One Process was closed down recently for other reasons after 1100 days running on Win98! Total Memory Leaks: 8096 Bytes. What's Happened ?
LateNightsInNewry
|
|
|
|
|
i am trying to draw 2D polygons and lines in C++ and i was wondering what libraries i can use. also are there any good tutorials i can refer to...
my end goal is to output a 2D square with a background color and some text inside of it...
any ideas/suggestions..? i have tried google and cant seem to find good resources..
thanks in advance.
--
dg
|
|
|
|
|
You can use GDI+. I've used it to create a form with a chart control (basically inherits panel) in Managed C++, and it wasn't really that hard to pick up. You can also use GDI+ with native code though.
|
|
|
|
|
nice..thanks!! this is probably a stupid question but after you download the .dll file off the ms website, where do you save it so all the classes work properly in my app??
--
dg
|
|
|
|
|
I am actually having trouble using GDI+ without getting compiler errors..
i have all my header files including GdiPlus.h in: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include
i have the GdiPlus.lib in: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib. i have also added GdiPlus.lib file in the additional dependencies of my project.
i have the .dll file stored in my local app directory..
when i #include GdiPlus.h, i get 107 compiler errors some of which are like the following:
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(520) : error C2146: syntax error : missing ';' before identifier 'ObjectTypeIsValid'
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(520) : error C2433: 'BOOL' : 'inline' not permitted on data declarations
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(520) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(523) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(548) : error C2065: 'META_SETBKCOLOR' : undeclared identifier
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(548) : error C2056: illegal expression
1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\GdiplusEnums.h(549) : error C2065: 'META_SETBKMODE' : undeclared identifier'
.. i am completely lost. any help on fixing this and enabling me to use GDI+ in my app without any trouble will be greatly appreciated.
--
dg
|
|
|
|
|
Sorry, I can't really help you out with setting up the environment for using GDI+ in native C++ as I've never done it myself -- I've only used the managed version.
As for your compiler errors, error C4430 typically indicates that you're missing the definition of a certain struct/class. The line number will tell you which one in particular it does not recognize, that you're trying to use.
|
|
|
|
|
Hello
How can i change the CLSID and progid for already existing projects.Should i generate this for each project using guidgen.exe?I want to be able to load the dlls from a different target path, as a seperate plugin.is it sufficient to change the clsid alone or should progid needs to be modified as well? What will be the efficient way to do this.
Thanks
|
|
|
|
|
I think the only practical way to do this is generate a new CLSID and paste it into the IDL file manually. Followed by a rebuild all. I have done this in the past to seperate different builds of COM objects.
Best Wishes.
-Randor (David Delaune)
|
|
|
|
|
Thanks for the reply David. Can i similarly change in the .rgs file associated with each project and do a rebuild all.The ProgID should not matter for loading dlls with same name from different target path right. Or can i manually change the last field of Project.ClassName.1 to Project.ClassName.2 in the .rgs file.I think the version independent progid can remain the same.
Thanks!
|
|
|
|
|
Yes, I forgot to mention that the .rgs files should also have the CLSID replaced. This is required to register the DLL and its interfaces. Technically the ProgID and the filename does not matter as long as all GUIDs have been changed. In fact; this why COM was invented (The cure for DLL Hell) although it failed miserably.
For the sake of completeness:
WinSxS (Side-by-Side) is Microsofts latest cure for DLL-Hell. http://msdn2.microsoft.com/en-us/library/aa374224.aspx[^]
Best Wishes,
Randor (David Delaune)
|
|
|
|
|
How is proxystubclsid generated?I find that in my application proxystubclsid is same as proxystubclsid32 and a default (same)value is used for all interfaces.
|
|
|
|
|
i am a multimedia student...next year i must develop a multimedia project to get my degree...can you all help me what is the suitable and the best project that i should develop...please give idea...thanks
kayana
|
|
|
|
|
This is a site for those who write actual code and the code does not work. Figure your own ideas on your own time.
______________________
stuff + cats = awesome
|
|
|
|
|
I am new to C++ have done some mainframe programming
I have a C++ question I figure Here is the best place to post it
What is the main advantage of having base and derevied classes instead of 2 seperate declarations
e.g.
Class MyClass : public CSstring
{
.
.
.
}
As opposed to
Class MYclass;
Class CSstring;
Is it that in former I can get at CSstring protected members/Methods ????
Thankx
|
|
|
|
|
There are many uses of inheritance, one of them being that you can develop interfaces. Inheritance is also a fundamental when it comes to using object-oriented design to solve problems. Depending on what kind of problems you are trying to solve and the complexity of the framework that you have to design, you may not use it much, or you may use it quite extensively.
In your example, yes, you can access protected members/methods, but that's not the reason why you'd use inheritance. If you have no need for any class hierarchy, then there might not be any benefits from using it.
|
|
|
|
|
its mainly a design thing The Base Class could be the lowest level interface, Where a user is Using a Object he/She may not need to access that low a level However the Derived Class may have a need for it
I have a project I want to write and I think once I get to coding I'll get a better feel for it
Thankx
|
|
|
|
|
What if you had a Car class and a Truck class? It wouldn't make much sense to have all of the common aspects duplicated between each. Instead, everything that is common to both a car object and a truck object should go in a base class (named Auto or Vehicle). Make sense? You could apply the same logic to:
Shape
/ | \
Ellipse Rectangle Triangle
| |
Circle Square And:
Animal
/ | \
Dog Cat Horse
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thankx I beginig to get the idea
|
|
|
|
|
Hello board, I want to print 10 columns in a list box so that it seems visually they are ordered in columns.
I use this code:
<br />
--- ------ ------ ------<br />
--- ------ ------ ------<br />
--- ------ ------ ------<br />
sInfo.Format(_T("%5d"), i);<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d1),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d2),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d3),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d4),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d5),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d6),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d7),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d8),<br />
sInfo.AppendFormat(_T("%9.3f ")), m_d9),<br />
Now , when I use this code deponding on number of significant digits in the double number, columns shift either to left or right(if number of digits are less than above row the whole row shifts to left and vice versa).
but when I use this code:
<br />
sInfo.Format(_T("%5d"), i);<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d1),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d2),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d3),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d4),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d5),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d6),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d7),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d8),<br />
sInfo.AppendFormat(_T("%09.3f ")), m_d9),<br />
everything becomes as I desire. I explain it in this way that size of blank characters that are placed in the first code is less than size of other digits. I actually do not like to see these zeros here(I wouldn't complain if these zeros were at right side of my bank account but not here ).
Is there anyway that blank characters be printed with the same size of other digits? thanks.
|
|
|
|
|
You could use a fixed-pitch font for the listbox:
LOGFONT logFont;
memset(&logFont, 0, sizeof(logFont));
logFont.lfHeight = -10;
logFont.lfWeight = FW_NORMAL;
logFont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
m_fixedfont.CreateFontIndirect(&logFont);
...
m_ListBox.SetFont(&m_fixedfont, FALSE);
m_ListBox.AddString(_T("0.01 123.12"));
m_ListBox.AddString(_T("0.01 23.12"));
m_ListBox.AddString(_T("0.01 3.12"));
m_ListBox.AddString(_T("0.01 123.12"));
m_ListBox.AddString(_T("0.01 123.12"));
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|