 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Hi,
i am confused about the return value of the clock_getres functions. I am running on custom hw with armv4 cpu and kernel version 2.6.26.
I get values 7812500 (nanoseconds) for CLOCK_REALTIME and CLOCK_MONOTONIC.
Can i trust that the resolution of gettimeofday (uses CLOCK_REALTIME?) calls is ~7.8ms? Does the CPU clock speed affect this value?
Regards
ele lont
|
|
|
|
 |
Most time functions have a resolution that is about on this order of magnitude. I've read somewhere that on most current systems the resolution is about 10-20ms, but 7.8ms sounds entirely reasonable too. And no, CPU speed doesn't matter.
Note that there are also functions for high-res time measurement. There is plenty of info about it on the web
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)
|
|
|
|
 |
You should. However you could also make a test.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
|
 |
<pre lang="text"> Could someone please help me to find my bug. This is C++ code "running" on Arduino. It compiles and runs ,but... I am using a struct to define / collect data which belong together. The bug is when I enter a character array (using pointer) into the structure variable, also a character array. The actual variable I am having problem with is ctextPrompts. I am sure there will be more, but this is the first bug. It is entered properly - verified by test code immediately after - see TOK here note. However, when I initialize next member of the struture cTextEntry - it wipes out the ctextPrompts. Initializing next structure member ctextEmulate puts ctextEmulate characters into ctextPrompts. This is my first attempt to utilize pointers and structure and I MUST have done something really stupid to cause this bug. I am using LCD to debug the code. Since the rest of the code works as expected I am pretty sure it is not a "memory" issue, I do verify the size of available RAM on initialization. I doubt it is a Arduino compiler issue, just plain wrong usage of pointers which I just do not see. I do apologize for the long code, but I feel it would help to see the debbuging attempts I have made so far. Thanks for your help. Cheers Vaclav PS While testing I am using both pointer (*) and indexing [0] with same results
</pre>char
*ctextEntry[] ={ " ", " "," " }; // emulating data char *ctextEmulate[] = { // emulate entries "14260123 ", // start frequency "14360000 ", // end frequency "10000 ", // step frequency "1 ", // step speed "1 ", // 0 single shot 1 repeat "Option" // }; // temporary not completed char *ctextPrompts[] ={ "Start frequency ","End frequency ","Step frequency ","Step speed ","Single / Repeat","Optional "};
typedef struct DataRecordTAG { char *cPrompts[]; // prompt text char *cEmulate[]; // emulate input char *cEntry[]; // response char cTEST; int iIndex; } DataRecord; DataRecord Record[DATA_STRUCT]; // variable int igRecordIndex = 0; // global access to records ....... void InitializeRecords(void) { // changed to global igRecordIndex igRecordIndex // igRecordIndex // initialize prompts and some test entries int iPromptIndex = 0; for(igRecordIndex = 0; igRecordIndex != DATA_STRUCT ; igRecordIndex++) // fence post error Optional missing { Record[igRecordIndex].iIndex = igRecordIndex; //test index not really needed /* TOK #ifdef FLOW_LCD lcd.clear(); lcd.print("Record[igRecordIndex].iIndex"); //too long lcd.setCursor(0,1); lcd.print(Record[igRecordIndex].iIndex); // too long delay(DELAY_LCD); #endif */ #ifdef FLOW_LCD TOK verified lcd.clear(); lcd.print("cPrompts empty "); lcd.setCursor(0,1); lcd.print(*Record[0].cPrompts); delay(5*DELAY_LCD); #endif
// prompt bug *Record[igRecordIndex].cPrompts = ctextPrompts[igRecordIndex]; //ReadRecords(); #ifdef FLOW_LCD TOK here lcd.clear(); lcd.print("cPrompts entered"); lcd.setCursor(0,1); lcd.print(*Record[0].cPrompts); delay(5*DELAY_LCD); #endif /* // BUG writes over previous record how ?? for(int i = 0; i < DATA_STRUCT; i++) { #ifdef FLOW_LCD lcd.clear(); lcd.print("igRecordIndex"); lcd.setCursor(0,1); lcd.print(igRecordIndex); delay(DELAY_LCD); lcd.clear(); lcd.print("Record[i].cPrompts"); lcd.setCursor(0,1); lcd.print(*Record[i].cPrompts); delay(5*DELAY_LCD); #endif } // BUG writes over previous record how ?? */ /* TOK #ifdef FLOW_LCD lcd.clear(); lcd.print("Record[igRecordIndex].cPrompts"); //too long lcd.setCursor(0,1); lcd.print(*Record[igRecordIndex].cPrompts); // too long delay(DELAY_LCD); #endif */
Record[igRecordIndex].cEntry[0] = ctextEntry[igRecordIndex]; // [DIGITS] #ifdef FLOW_LCD BUG now the cPrompts is empty lcd.clear(); lcd.print("cText entered"); lcd.setCursor(0,1); lcd.print(*Record[0].cPrompts); delay(5*DELAY_LCD); #endif
*Record[igRecordIndex].cEmulate = ctextEmulate[igRecordIndex]; // emulate input #ifdef FLOW_LCD BUG the cPrompts contains ctextEmulate - index 0 lcd.clear(); lcd.print("ctextEmulate entered"); lcd.setCursor(0,1); lcd.print(*Record[0].cPrompts); delay(5*DELAY_LCD); #endif
/* TOK #ifdef FLOW_LCD lcd.clear(); lcd.print("Emulate "); //too long lcd.setCursor(0,1); lcd.print(Record[igRecordIndex].cEmulate); // too long delay(DELAY_LCD); #endif */ } igRecordIndex = 0; ReadRecords(); for(;;); /* TOK #ifdef FLOW_SERIAL Serial.println("Prompts initialized DONE "); #endif #ifdef FLOW_LCD lcd.clear(); lcd.print("Prompts initialized DONE "); delay(DELAY_LCD); #endif */ }
|
|
|
|
 |
Quote: *Record[igRecordIndex].cPrompts = ctextPrompts[igRecordIndex];
What are you doing with this line?
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
 |
Initializing the struct member cPrompts (char array) from ctextPrompts (char array). According to next verification code it works. But than things go crazy as described.
|
|
|
|
 |
There maybe be several bugs, but I believe you should remove the []:
ypedef struct DataRecordTAG
{
char *cPrompts; char *cEmulate; char *cEntry;
char cTEST;
int iIndex;
}
|
|
|
|
 |
I think what I am doing is assigning pointers in the structure to point to an array. Is that legal / right? Or do I need to physically copy the array to the structure? That will probably wipe out the memory for good. I am sure lost in this . Maybe I need to not use the structure at all.
|
|
|
|
 |
Now that does not "copy" the entire array into the structure. But I think I need to work on making the structure pointer equal the array pointer.
|
|
|
|
 |
I did remove the array and so far it is working. But I need to check the rest of the code . Thanks Vaclav So basically if read my code in English = assigning a char pointer to point to pointer to array of characters. What I did was wrongly assign a char array pointer to point to array of characters. Thanks to both of you guys to nudge me the correct this. Vaclav
-- modified yesterday.
|
|
|
|
 |
Hi
I want to call a ASP.Net (.asmx) from a MFC 2008 project.
My PC has Windows 7, but I want to run my program from Windows XP and 7 (I need to support Winsows XP)
(Some years ago I did this in VC++2003 but add web refrence is not included in VC++2008)
Any suggetstion?
Regards
www.logicsims.ir
|
|
|
|
 |
Hello. How do I execute certain batch files and shell scripts along with my project? Are these settings specified in Pre Build and Post Build events in visual studio? Thanks for any input.
This world is going to explode due to international politics, SOON.
|
|
|
|
 |
AmbiguousName wrote: Are these settings specified in Pre Build and Post Build events in visual studio? Thanks for any input. Yes, depending on which part of the build process you want them.
|
|
|
|
 |
All right let's suppose I want Pre Build. Now how do I tell Visual Studio to use xxxx.sh and xxxx.bat files?
This world is going to explode due to international politics, SOON.
|
|
|
|
 |
Go to the Project Properties, click on Build Events, Pre-build, and add the details as required.
|
|
|
|
 |
Since I have never done this, so bear with me. Do I have to add some kind of path? Suppose a xxxx.bat file is at desktop, would the entry be like this: call ..\..\Desktop\xxx.bat ?
This world is going to explode due to international politics, SOON.
|
|
|
|
 |
Yes, the same as you would do in any application or command shell. However it probably makes more sense to add the batch files into your project directory so they stay with the project. That also allows you to manage them within your source control system as well.
|
|
|
|
 |
<blockquote class="quote"><div class="op">Quote:</div>float determinant1(float **a,int n)
{
int i,j,j1,j2 ; float det = 0 ; float **m = NULL ;
if (n < 1) { }
else if (n == 1) { det = a[0][0] ;
}
else if (n == 2) { det = a[0][0] * a[1][1] - a[1][0] * a[0][1] ; }
else { det = 0 ;
for (j1 = 0 ; j1 < n ; j1++) {
m = (float **) malloc((n-1)* sizeof(float *)) ;
for (i = 0 ; i < n-1 ; i++)
m[i] = (float *) malloc((n-1)* sizeof(float)) ;
for (i = 1 ; i < n ; i++) {
j2 = 0 ; for (j = 0 ; j < n ; j++) {
if (j == j1) continue ;
m[i-1][j2] = a[i][j] ; j2++ ; }
}
det += pow(-1.0,1.0 + j1 + 1.0) * a[0][j1] * determinant1(m,n-1) ;
printf("\n%f",det);
for (i = 0;i<n-1;i++) free(m[i]) ; free(m) ; }
}
return(det) ;
}
</blockquote>
|
|
|
|
 |
Check your compiler documentation on how to increase the stacksize. Very likely your program dies due to stack overflow. This tends to happen when you have very deep levels of function calls, and 100 levels of recursion qualifies as very deep!
Alternately, test your program with smaller matrices, say 10x10 rather than 100x100. If it works, it's a stack overflow issue.
To prevent stack overflow, the only safe method is to avoid recursion, i. e. you should transform your program into one that doesn't require recursion. Otherwise you need to set a maximum recursion level and a set a stacksize that is sufficient to run the program with the maximum defined recursion level; you should exit the program with an error message, if the input would lead to a recursion level exceeding the predefined maximum.
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)
|
|
|
|
 |
thank you for ur suggestion but can u kindly tell me how to set the maximum recrusion size or else the without recrusion process..
|
|
|
|
 |
What I meant is, check programatically the depth of your recursion. E. g. define a static counter within your recursive function, and always compare it to the maximum allowed value, like this:
const int max_recursion_level = 20;
int foo(int n) {
int result = 0;
static int recursion_level = 0;
++recursion_level;
if (recursion_level > max_recursion_level)
throw("recursion level exceeded!");
if (n<=0)
result = 0;
else if (n==1)
result = 1;
else
result = foo(n-1) + foo(n-2);
--recursion_level;
return result;
}
As for calculating the determinant without recursion, I am sure there are plenty of algorithms on the web if you search for it. I?ve found one in the first response to this question: http://cboard.cprogramming.com/cplusplus-programming/30001-determinant-calculation.html[^]
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)
|
|
|
|
 |
Actually i am confused now do i need to call int foo() inside the determinant()? if at all i have to set counter can u please help me to implement in my code.
|
|
|
|
 |
No, to simplify matters I programmed a recursive function, foo(). It is an implementation of the Fibonacci sequence. The only actual code of that function is the if/else/else-if block.
In your case, the determinant function is the recursive function. To check the recursion level, you should do the same as I did for foo(): add a static counter variable that is initialized to 0, define a maximum recursion level somewhere accessible, and maintain that counter when you enter and leave your function.
Note that all of my advice is based on the assumption that your problem is caused by a stack overflow. It is an educated guess of mine, but I cannot test it, because I don't know what compiler and what settings you are using. Have you verified this is the cause of your problem? If not, then following my advice may not solve it!
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)
|
|
|
|
 |
So nice of fren i set the recrusion_level in my program and while running its displaying exceed recrusion level as per printf i wrote and in infinte.any suggestion i really need to overcome this.
|
|
|
|
 |
I think you do not understand: maybe you should just forget the recursion counter - it is only a safeguard, and will not help you calculate the determinant!
Please check out the link to code I posted above. It does not use recursion and therefore does not need a counter. And it might even be slightly faster.
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 Need to trace the printing process from any application in windows. If User prints any document or file from any application Need to get printing information like printer name, No. of pages, Types of paper, and other setting in the print dialog. my application triggered when print is given.
Thanks in Advance.
Have A Nice Day!
Murali.M
Blog
|
|
|
|
 |
And do you have a question?
|
|
|
|
 |
std::map <iCString,unsigned int> mCounters;
//This function populate the "mCounters" map
GetCounters(mCounters);
map< iCString,unsigned int>::iterator it;
for (map<iCString,unsigned int>::iterator it = mCounters.begin();
it = mCounters.end(); ++it)
{
}
I am getting the error mentioned in the subject... what is the mistake I am doing ?
Fulll Error message
------------------
error C2451: conditional expression of type 'std::_Tree_iterator<_Mytree>' is illegal
1> with
1> [
1> _Mytree=std::_Tree_val,std::allocator>,false>>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
|
|
|
|
 |
You missed a symbol from the middle of your for loop expression.
it = mCounters.end()
should be
it != mCounters.end()
|
|
|
|
|
 |
(This does reference previous projects but I suggest deserves a new thread as it is a particular issue with TB_HIDEBUTTON and no other API).
I have discovered some apparently random behaviour of TB_HIDEBUTTON on Windows 7 64-bit. I have not tested on any other OS but suppose the problem will be duplicated to some degree or other.
First, I have a project (of my own) which successfully enumerates the toolbar buttons in the Notify Area.
One starting project to illustrate the idea, is this:
http://www.codeproject.com/Articles/10807/Shell-Tray-Info-Arrange-your-system-tray-icons
(This is an old project - for my Win7 it needs modifying to make the TBBUTTON structure fixed to 6 reserved bytes, also a mod to find the hwnd Win 7 "User Promoted Notification Area", so it's not a perfect sample but good enough to illustrate the type of code loop i'm using.)
I've used TB_BUTTONCOUNT to obtain a count of buttons on the Notification Toolbar, have entered a loop iterating over those items as i, and have created memory in the target process to retrieve the TBBUTTON structure and its TRAYDATA structure. I have then used GetWindowThreadProcessId to get tray.hwnd and from there have been able to extract all the required information in my loop regarding the target button. This all works.
The problem is, that being in my loop of i, I can successfully delete buttons with TB_DELETEBUTTON (and also, in the sample above with mods, can successfully use TB_MOVEBUTTON as well.) I'm therefore certain that my loop of i is pointing at the correct button. My pointer enumerator (actually an index i for SendMessage) appears to be, therefore, correct, as in, it is pointing at the correct button on the list in each iteration. That's logical.
However, TB_HIDEBUTTON produces bizarre and unexpected results - it hides the wrong button every time.
The only thing I can suppose in this circumstances is that the TB_HIDEBUTTON API has a wierd bug.
Can anyone confirm what is the problem hiding buttons with this API?
LRESULT hideResult = SendMessage(hTrayWnd, TB_DELETEBUTTON, i, 0 );
LRESULT hideResult = SendMessage(hTrayWnd, TB_HIDEBUTTON, i, 1 );
|
|
|
|
 |
According to the documentation[^], the WPARAM value should be the command id of the button, not an index.
|
|
|
|
 |
Correct. The API def for DELETEBUTTON specifies an Index whereas Command Identifier is presumably the idCommand field of TBBUTTON.
The API docs are different for each function.
Having tested this using the idCommand field of TBUTTON, rather than the Index, it works.
Problem solved. Many thanks.
|
|
|
|
 |
please how to fix this problem ? I installed Micrsoft viuasl studio profissional 2013 >> mex -setup Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www.mathworks.com/support/compilers/R2013a/win64.html Please choose your compiler for building MEX-files: Would you like mex to locate installed compilers [y]/n? y No supported SDK or compiler was found on this computer. For a list of supported compilers, see http://www.mathworks.com/support/compilers/R2013a/win64.html Error using mex (line 206) Unable to complete successfully.
|
|
|
|
 |
I thought you could include this in VS by just adding a DLL file?
But Google[^] should explain how to do it.
|
|
|
|
 |
Hi All,
I am using VS 2010 (SP1). When I am trying to use Edit and continue for debugging X64 bit application, I am getting the following error,
"the source file has changed it no longer matches the version of the file used to build the application being debugged"
Is there anyway to get rid of this?
OS: Win2008server (64 bit)
Thanks,
SMA
|
|
|
|
|
 |
Hi Richard,
Thanks for your reply..Its mainly intended for VS2013. I am not able to do for VS2010
Thanks,
SMA
|
|
|
|
 |
Well now you know where to look you can get any specific details for VS2010.
|
|
|
|
 |
Hi Richard,
Thanks again for your reply. Actually I came to know from link that "Edit and continue" feature is not available for X64 bit application in VS2010..In order to be make sure I wanted to hear it from expert team who had already having hands on experience on this.
Thanks,
SMA
|
|
|
|
 |
Well thanks for your comment, but I have never used Edit & Continue in 20 years of Windows programming.
|
|
|
|
 |
I'm going to have to second Richard on this... I've never used Edit & Continue... I wouldn't depend on a feature that's not really widely used as that (none of the other developers in my company use it either).
|
|
|
|
 |
I have never used it either.
Rather curious as to what development methodology would be in use such that this would be a feature that one could ever rely on in a non-trivial way.
|
|
|
|
 |
Yeah, I'd be curious too. It's not a very helpful feature, sounds more like a feature added for the sake of adding bullet point highlights for a new release of VS.
|
|
|
|
 |
I very rarely use it to fix minor typo-like errors, such as replacing < with <= , or changing literal values in assignments or function calls to something else. The reason is that I'm often confronted with deep levels of function calls with multiple nested loops, and getting back to the same point of debugging can be very time consuming.
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)
|
|
|
|
 |
True, but nothing that you couldn't do with a bookmark and/or a conditional break point.
|
|
|
|
 |