|
AdvancedCPP wrote: I have not really used in my c++ code practically
You have either to change that or your nickname.
Veni, vidi, vici.
|
|
|
|
|
I am creating an application that is multithreaded and all the threads are accessing the same shared memory. The data coming into the memory should be processed in sequential order. Like if 1,2,3,4,5 comes in the memory then it should be processed in same order.
I have used critical section around my memory, but I still get into a race condition where data is not grabbed by the thread in sequential order.
Am I missing anything else to prevent threads from race condition?
Thanks.
ACpp
|
|
|
|
|
Yes, you are.
Google 'multi thread patterns'.
It is a long path, but when you arrive, you're likely to feel it was worth it.
Pablo.
"Accident: An inevitable occurrence due to the action of immutable natural laws." (Ambrose Bierce, circa 1899).
|
|
|
|
|
Can I run two command line instructions on a file in a VS2008 project? I can set each command line instruction up as a rule in the .rules file (see below) but can only select one rule or the other not both. From the input files properties in VS2008 Project View I can select GraphVizSVGRule or GraphVizPNGRule . I want to create both a .svg file and a .png file from the input .gv file (GraphViz)
="1.0"="utf-8"
<VisualStudioToolFile
Name="GraphViz Rule File"
Version="8.00"
>
<Rules>
<CustomBuildRule
Name="GraphViz Dot to SVG Rule"
DisplayName="GraphVizSVGRule"
CommandLine="dot.exe -T svg "$(InputDir)\$(InputName).gv" -o "$(InputDir)\images\$(InputName).svg""
Outputs="$(InputDir)\images\$(InputName) .svg"
FileExtensions="*.gv"
ExecutionDescription="builds svg file"
>
<Properties>
</Properties>
</CustomBuildRule>
<CustomBuildRule
Name="GraphViz Dot to PNG Rule"
DisplayName="GraphVizPNGRule"
CommandLine="dot.exe -T png "$(InputDir)\$(InputName).gv" -o "$(InputDir)\images\$(InputName).png""
Outputs="$(InputDir)\images\$(InputName) .png"
FileExtensions="*.gv"
ExecutionDescription="builds png file"
>
<Properties>
</Properties>
</CustomBuildRule>
</Rules>
</VisualStudioToolFile>
|
|
|
|
|
The only method I have found to run more than one is to create a command script that accepts parameters, so you can pass in the file and directory names.
Use the best guess
|
|
|
|
|
Thanks, it's now working with the below as you suggested.
Rule that calls batch file:
<CustomBuildRule
Name="GraphViz Dot to PNG and SVG"
DisplayName="GraphVizPNGSVGRule"
CommandLine="images "$(InputDir)\$(InputName).gv""
Outputs="$(InputDir)\images\$(InputName).png;$(InputDir)\images\$(InputName).svg;"
FileExtensions="*.gv"
ExecutionDescription="builds png and svgfile"
>
<Properties>
</Properties>
</CustomBuildRule>
Batch file that creates svg and png from GraphViz gv file:
echo off
set "p=%~dps1"
set "px=Images\"
set "newp=%p%%px%"
set "newsvg=%newp%%~n1%.svg"
set "newpng=%newp%%~n1%.png"
set "source=%~s1"
echo Creating svg...
dot.exe -T svg %source% -o %newsvg%
echo Creating png...
dot.exe -T png %source% -o %newpng%
|
|
|
|
|
Hello Friends
Application is Compiled on VS2010 in WinXp and it is crashing on Win8 when ivoked by Menu not crashing by shortcuts.
Isn't issue with running application on 64 bit Machine ?
Reagrds
Y
|
|
|
|
|
You are not really providing us with enough information here and I am not sure I understand the difference between launching the application from a menu versus from a shortcut.
However, I think it could be because the shortcut is setting the applications startup folder to be the installation folder, whereas that is not being done when it is launched from the menu.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
modified 7-Jun-13 7:32am.
|
|
|
|
|
You will need to provide a lot more information than the above if you want some assistance. Try getting some debug information and show the failing code.
Use the best guess
|
|
|
|
|
I am opening a simple Dialog on Menu->SubMenu And also using keyboard Shotcut too.
But, When I Click on Ok of that Dialog ,it completes its execution and then go to Dissembly.
But If I do same process using Keyboard shortcut then everything is fine.
|
|
|
|
|
I see that I guessed completely wrong when I thought I understood what you were saying. You can disregard my answer as it obviously has nothing to do with that.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
You really should know by now that we cannot guess what is happening in your cpode, nor can we see your screen. Please edit your question and provide some proper technical information.
Use the best guess
|
|
|
|
|
|
Sorry, but I don't think anyone is likely to be downloading that and doing your job for you.
Use the best guess
|
|
|
|
|
hi guys.. I have written the below code in C. I have 3 bits in three different integer variables. How can I concatenate those values assuring that i need only binary values (1/0).
#include <stdio.h>
#include "manojturbo5.h"
#include "bitsconv.h"
#include "manojencoder2.h"
void main()
{
int message,interleaver,u,p,q,r,final,result,i;
printf("Enter the message\n");
scanf("%d",&message);
bitconv (message);
for(r=0;r<32;r++)
{
u = array[31-r];
p = encoder(array[31-r]);
q = encoder2(array[31-r]);
printf("%d\t %d\t %d\n",u,p,q);
}
return;
}
|
|
|
|
|
Do you really think you will get any different answers than here[^], which you all didn't seem to like?
|
|
|
|
|
I cannot use shifting operator because it will give numbers other than 1/0. If I shift it once i will get 2. I dont want that. I need only binary (1/0).
|
|
|
|
|
Manoj7390 wrote: I cannot use shifting operator because it will give numbers other than 1/0. <layer>
that makes no sense at all.
Manoj7390 wrote: If I shift it once i will get 2.
1 = 00000001 (in binary)
1 << 1 = 2
2 = 00000010 (in binary)
you might benefit from reading about binary math and how computers store numbers.
|
|
|
|
|
I was reading the previous thread and I think the problem you are having is understanding the difference between storing the values and using the values.
Richard showed you how to pack the three binary values into a single integer:
int Answer = (u << 2) | (p << 1) | q
That is for storing them. Don't worry about the actual value of Answer. When you need to use the binary values, you have to unpack them. There are different ways to do it, but I think this method is the easiest way for you to understand it:
q = Answer & 1;
p = (Answer >> 1) & 1;
u = (Answer >> 2) & 1;
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
There are so many things wrong with this piec of code, I suggest you go back to your reference manual and read about types, variables and functions. And work through a lot of the samples.
Use the best guess
|
|
|
|
|
I got this error message when I debug:
Unhandled exception at 0x77a915de in MSW_Vib_Model.exe: 0x00000000: The operation completed successfully.
from these code segments:
//
ifl=0;
do {
{
//
fscanf_s(f_ptr_seed_inf,"%lf %lf %s\n",&sd_dis[ifl],&time_onset[ifl], ftitle[ifl].GetBuffer(MAX_PATH));
ftitle[ifl].ReleaseBuffer();
}
ifl += 1;
} while (!feof(f_ptr_seed_inf)&&(ifl<120));
nfile=ifl;
//
This is my input file:
4171.000 0.28600 ECO61_4171_Hole1_seeds.txt
4157.000 0.24600 ECO61_4157_Hole2_seeds.txt
Please help me.
|
|
|
|
|
The problem is readying the string with fscanf_s .
If you replace fscanf_s with fscanf , you will notice that it works without errors.
The _s (secure) versions of the C-Runtime requires that the size of the buffer be known and this is validated by the function.
So you need to pass in the size of the string as an argument following the actual string buffer as shown -
fscanf_s(f_ptr_seed_inf,"%lf %lf %s\n",&sd_dis[ifl],&time_onset[ifl], ftitle[ifl].GetBuffer(MAX_PATH), MAX_PATH);
Here is an excerpt from the documentation for scanf_s -
Unlike scanf and wscanf, scanf_s and wscanf_s require the buffer size to be specified for all input parameters of type c, C, s, S, or string control sets that are enclosed in []. The buffer size in characters is passed as an additional parameter immediately following the pointer to the buffer or variable. For example, if you are reading a string, the buffer size for that string is passed as follows:
char s[10];
scanf_s("%9s", s, _countof(s)); // buffer size is 10, width specification is 9
|
|
|
|
|
Hi All,
I have a BOOST test case as below
BOOST_AUTO_TEST_CASE( BoostUnitTestSample )
{
// seven ways to detect and report the same error:
BOOST_CHECK( add( 2,2 ) == 4 ); // #1 continues on error
BOOST_REQUIRE( add( 2,2 ) == 4 ); // #2 throws on error
somefunction_whichleaksmemory();----------->memory leak function.
if( add( 2,2 ) != 4 )
BOOST_ERROR( "Ouch..." ); // #3 continues on error
}
I want to programmatically detect the memory leak in function somefunction_whichleaks() and get information like line number and filename where the leaked occurred.
And most importantly I should know in which test case this leaked occured.May be I would like to have a dump of all this information in some file.
Does anybody knows a solution to this?
|
|
|
|
|
If you're using MFC, add this snippet above your code:
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
Your memory leaks will then appear in the output window.
Note that it doesn't work correctly with overloaded new constructors, so for those you may need some $ifdef guards.
|
|
|
|
|
I am not able to understand the output of below lines.
As per my understanding output should be 8 because we are subtracting int address which is having 8 byte diffrence but output is coming 2. Please expalin.
int a[]={5,10,15,20};
int d = &a[2]-&a[0];
|
|
|
|