|
Don't trace. It's very hard to estimate the amount of information needed whithout flooding the output with pointless redundand information. Also the printed information is difficult to associate with the actual control flow, if the traced function can be called from different points in your code.
Judo Sarabia wrote: how to determine the flow of the program?
Use a debugger, step through the code, and analyze the state of your program at your pace. You can check the call stack whenever you like to determine how you arrived at the function, and what happened earlier, or where the function arguments came from.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Hi, I am trying to read program flash on a pic18f67k22.
From the datasheet...
"The TBLRD instruction is used to retrieve data from
program memory and places it into data RAM"
example in ASM...
TBLRD*+
How do I execute "TBLRD*+" in 'C'?
- Thanks
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
|
Check out the documentation of the compiler you are using, possibly it provides a builtin function for this very purpose (for instance, the C30 compiler, for PIC24 devices, has something like that). As an alternative method you may always use inline assembly instructions in the C code (as far as I know all the PIC compilers support inline assembly). In any case, read carefully the compiler's documentation.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Thanks CP.
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
|
You are welcome.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Perhaps use inline assembler, employing the _asm and _endasm directives?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
I've to do the searching process through the 2-3 tree by storing the roll number s of the students as keys in the tree. The tree node will contain a pointer to the doubly node in the doubly linked list.
I included the doubly node pointer as a private member in the tree node class
Then tried to merge the 2-3 tree nodes with the student objects
Node<Student> *s1,*s2,*s3,*s4;
s1 = new Node<Student>;
s1->data.setData("Hamza",12105092);
s2 = new Node<Student>;
s2->data.setData("Sherlock",12105102);
s3 = new Node<Student>;
s3->data.setData("Watson",12105022);
s4 = new Node<Student>;
s4->data.setData("Spidey",12105042);
Course c1("OOP",3.52,"A");
Course c2("DM",4,"A+");
Course c3("DLD",3.2,"A-");
CTree<Student> *tree1;
tree1 = new CTree<Student>();
tree1->insert(new Student("",12105092));
tree1->insert(new Student("",12105042));
tree1->insert(new Student("",12105102));
tree1->insert(new Student("",12105022));
tree1->findOWN(new Student("",12105092))->merge(s1);
tree1->findOWN(new Student("",12105102))->merge(s2);
tree1->findOWN(new Student("",12105022))->merge(s3);
tree1->findOWN(new Student("",12105042))->merge(s4);
doublyLinkedList<Student> d1;
d1.insert(s1);
d1.insert(s2);
d1.insert(s3);
d1.insert(s4);
Relevant 2-3 tree methods
template<class T>
CNode<T>* CTree<T>::findOWN(T*pKey)
{
CNode<T> *pNodeFound= 0;
bool bKeyFound = false;
search(pKey, &pNodeFound, &bKeyFound);
if(bKeyFound == true &&
TCompare(pKey, pNodeFound->getSmallKey()) == EQUAL)
{
return pNodeFound;
}
else if(bKeyFound == true &&
pNodeFound->getSize() == threeNode &&
TCompare(pKey, pNodeFound->getBigKey()) == EQUAL)
{
return pNodeFound;
}
else
{
return 0;
}
}
template<class T>
int CTree<T>::TCompare(const T* const pT1, const T* const pT2) const
{
int iReturnCode = FAILURE;
if(*pT1 < *pT2)
{
iReturnCode = LESS;
}
else if(*pT2 < *pT1)
{
iReturnCode = GREATER;
}
else
{
iReturnCode = EQUAL;
}
return iReturnCode;
}
1. Some how the merging's aren't completely right e.g in case where there are two key values in a node then it mixes up the merging when I try to search 12105022 I should be getting "Watson" but I get "Spidey" instead, how to fix that?
|
|
|
|
|
Hamza Bin Amin wrote: ...it mixes up the merging when I try to search 12105022 I should be getting "Watson" but I get "Spidey" instead, how to fix that? So have you single-stepped through the code using the debugger?
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I suppose you should show the complete code in order to get help.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
1. the line
tree1->findOWN(new Student("",12105092))->merge(s1);
creates a memory leak, as the function argument is created on the heap, but never deleted.
2. your function CTree<t>::TCompare compares objects of type Student using
operator<(const Student&, const Student&) Did you define that operator? If not, the result of these comparisons are undefined. If you did, the error may be within the code of that operator definition.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
|
Member 10914803 wrote: Due to the sensitive nature of this project and the intellectual properties involved, we prefer to keep our exposure to a minimum. Thus, if you're interested in possibly getting involved then please reply here... "That's funny right there!" -- Mater
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Member 10914803 wrote: keep our exposure to a minimum
The Backroom[^] would meet your requirement.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
Member 10914803 wrote: I am a seasoned Software Engineer
Does that mean you are covered with herbs and spices?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
|
Hello guys. I am trying to make and use a dll in VC++. I am following this sample. The dll compiles successfully. But when I try to integrate it's .dll, .lib and .h files in another project, then it gives me 5 linker errors. One of them is Error LNK2019 and rest are Error LNK2001. Couple of them look like this
1 - error LNK2019: unresolved external symbol "public: __thiscall CMyClass::CMyClass(void)" referenced in function "public: __thiscall CClientDlg::CClientsDlg(class CWnd *)"
2 - error LNK2001: unresolved external symbol "public: __thiscall CMyClass::~CMyClass(void)"
Just to let you know, I make a new folder and put all the said files in it. Then I add this path to the following properties
+ Properties-> Linker-> General-> Additional Library Directories<br />
+ Properties-> C/C++-> General-> Additional Include Libraries
What could I be doing wrong here? Thanks for any pointer.
|
|
|
|
|
|
Is that one of your export classes? ...how is it defined in the header? ...make sure you've labeled it as an import (that's the declspec part of the example) in the header file.
One thing I noticed about that example is that it's exporting functions, not really exporting classes. Difference is the constructor, if you're exporting/importing a whole class, this[^] is the way to do it. Look at the section labeled as "C++ Native Approach: Exporting a Class".... although it wouldn't hurt to read the whole article so you know get as much info as possible.
|
|
|
|
|
I am using a Windows host machine to cross compile programs on to a Linux RT platform using a GCC cross compiler.
Assume, the C program I write, links to a shared library libShared.so as I am using functions defined in that library inside my program.
In the Eclipse editor I am providing the library name (libshared.so), and its path under linker options. Now when I compile the program, I get compilation errors since libShared.so links to multiple other libraries (eg: lib11.so, lib12.so, lib13.so), but I am not explicitly calling any functions from these libraries.
My question is, Why should the compiler generate errors, when I don't explicitly use functions defined in those libraries ?
However when I specify the name and path of the libraries liked by libShared.so, the compilation passes.
|
|
|
|
|
Quote: Why should the compiler generate errors, when I don't explicitly use functions defined in those libraries ? Because libShared does.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
I know that if you allocate an object on the heap using 'new', it needs to be deleted.
But what if it's a function that returns a pointer to an object?
For example...
SomeClass *someClass = aFunction();
I'm assuming that inside of aFunction(), there is a 'new Someclass()' in there somewhere.
However... When I delete someClass on app exit, the app crashes. If I comment out the
delete, it exits ok. But won't there be a memory leak if someClass isn't deleted?
|
|
|
|
|
it's impossible to say.
is aFunction returning a pointer to a global, or to an object that is it managing somehow ?
|
|
|
|
|
Don't assume that a pointer you get has been created with new . Read the code, or documentation, to find out what your responsibilities are.
It might have been created with new , in which case you need to call delete when you are done with it. It might have been created with malloc (or one of its relatives), in which case you need to call free when you are done with it. It might point to a global or static piece of data, in which case you don't release it.
Never assume when it comes to memory management.
In this case, it seems likely you do not need to release the pointer, but the only way to be sure is to read up on how it is created and what your responsibilities are.
|
|
|
|
|
DanielSheets wrote: However... When I delete someClass on app exit, the app crashes. At any point do you reassign or increment someClass such that it points to a different location? For example:
SomeClass *someClass = new SomeClass();
someClass++;
delete someClass;
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|