|
|
Richard, but there was just a wrong forum!
Therefore (I think) he has reposted the question here....
|
|
|
|
|
Erich Ruth wrote: ...I get an error in this code: What error?
Erich Ruth wrote: It breaks... What does that mean, exactly?
Could it be a difference between release vs. debug mode? Have you stepped into LeaveCriticalSection() to see what is happening (e.g., fired assertion)?
"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
|
|
|
|
|
When I say it breaks, that means it pops up a box that says:
"Unhandled exemption x 0x777f6a73 in MultiScreen.exe: 0xC0000005: Access
violation reading location 0xfeeefefa.
and then I have Break or Continue. I hit Break and it shows me this code:
inline void* CThreadSlotData::GetThreadValue(int nSlot)
{
EnterCriticalSection(&m_sect);
ASSERT(nSlot != 0 && nSlot < m_nMax);
ASSERT(m_pSlotData != NULL);
ASSERT(m_pSlotData[nSlot].dwFlags & SLOT_USED);
ASSERT(m_tlsIndex != (DWORD)-1);
if( nSlot <= 0 || nSlot >= m_nMax )
{
LeaveCriticalSection(&m_sect);
return NULL;
}
CThreadData* pData = (CThreadData*)TlsGetValue(m_tlsIndex);
if (pData == NULL || nSlot >= pData->nCount)
{
LeaveCriticalSection(&m_sect);
return NULL;
}
void* pRetVal = pData->pData[nSlot];
LeaveCriticalSection(&m_sect);
return pRetVal;
}
and its pointing to
LeaveCriticalSection(&m_sect); which is the 2nd to last line.
|
|
|
|
|
Hi,
0xfeeefeee is a magic number[^] used by the debug heap for marking memory that's been freed. So it looks like the data at pData->pData[nSlot]; has already been freed by the time you try to read it.
This probably means that the bug also exists in your 'Retail build'. A retail build with a normal heap may happily read garbage data and keep on going.
You can probably debug this by setting up a memory watch[^] for &pData->pData[nSlot];
Best Wishes,
-David Delaune
|
|
|
|
|
Could somebody please correct this code for me ?
I am trying to pass char array to a constructor and USE
LIST to initialize the class variable.
I can do single char - USING LIST - no problem, I can pass a variable and copy it to class variable.
I am trying to learn more about using LIST AND I am hopelessly lost
how to pass a char array - preferably "by pointer".
I have tried all kinds of syntax combinations, samples etc. but I really need some help.
Appreciate any inputs.
<pre lang="c++">
// passing an array of char
char array[16];
public:
CLASS_SPI_NEW(char array): array(array)
{
}</pre>
|
|
|
|
|
Vaclav_ wrote: <pre lang="c++">
// passing an array of char
char array[16];
public:
<b>CLASS_SPI_NEW(char array): array(array)</b>
{
}</pre></blockquote>
Did you probably mean
CLASS_SPI_NEW(char* array): array(array)
|
|
|
|
|
Thanks for the suggestion , here is what I did and it works.
Two more questions
The array actually gets filed with 12 characters and I have "sized" it for two.
This "list constructor " code syntax have no "prototype", but it works.
<pre> char *array = " ";
int channel;
long speed;
int mode;
C_SPI_NEW(char *array, int channel, long speed, int mode )
: array(array), channel(channel), speed(speed), mode(mode)
{
#ifdef DEBUG
cout << "\033[1;31mConstructor \033[0m\n";
cout <<" device " << array <<endl;
cout <<" channel " << channel << endl;
cout <<" speed " << speed << endl;
cout <<" mode " << mode << endl;
cout << " function " << __FUNCTION__ << endl;
cout << " line " << __LINE__ << endl;
#endif
}</pre>
|
|
|
|
|
Is there some very important reason to use plain char array instead of std::string or MFC CString class?
|
|
|
|
|
Yes, but it is complicated.
Since you asked-
I am using PC to remotely compile C++ code for Raspberry Pi.
No MFC needed.
My OS is Ubuntu and my IDE is Eclipse. I have no problem using String on PC locally, but the OS on Raspberry Raspbian complains about wrong version of some library.
When I check the version in question it is current.
Instead of trying to figure out something over my head I simply do no use String.
My application is pretty much "low level bits" communication anyway.
Problem solved.
|
|
|
|
|
Hello All,
I have C++ dll, that has some exposed functionality using Def files, among all those CPP files there is one Cpp (Lets call it "Generator.cpp") files that dosnt gets compile normally but it is used to generate supporting C++ file that is exposed in Def files.(some how...some developer thought process, Legacy code)
the Generator.cpp looks like this
#ifdef _USRDLL
#pragma comment(linker, "/EXPORT:GenerateFiles=?GenerateFile@@YGJPAUHWND__@@PAUHINSTANCE__@@PADH@Z")
#endif
__declspec(dllexport) HRESULT __stdcall GenerateFiles(HWND hwnd,HINSTANCE hinst,LPSTR lpCmdLine,int nCmdShow)
{
}
can some body help what commandline parameter i should pass so that possible EXPORT can happen and CPP file would be generated.
vikas da
|
|
|
|
|
|
I already explained that we do not have enough information. We have no idea what this code is for or how it is accessed from other applications.
|
|
|
|
|
This may be too silly to ask here , really a hardware question , but I am stuck.
I am using ioctl to write to I2C device - LCM1602.
This device uses PCF8574 "I2C interface chip" to connect to HD44780 Hitachi LCD controller in <b>4 bits mode</b> .
Setting the HD447890 into 4 bit mode is well documented, but..
After the HD44780 is set into 4 bit mode further configuration need to be set using TWO (I2C sends 8 bits but only 4 bits are valid ) data "packets" after the single I2C address is send.
I have this single address plus data working and cannot figure out HOW to
add another "buffer" so I can send TWO 8 bits words.
The I2C spec requires to wait for ACK after the first 8 bit data is send, so I just cannot add the data into single buffer.
PLEASE - THE ATTACHED CODE IS WORK IN PROGRESS, REDUNDANT ETC , BUT IT WORKS!
ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED.
However, I'll appreciate any suggestions on how to send
ONE address byte and multiple data bytes in I2C format.
Thanks.
<pre lang="c++">
// original expanded
// write directly to expander using ioctl file descriptor
// and plain write(fd,data,#)
// parameters
// int file file descriptor
// char data data to write
// int NumberOfCharacters to write
// return 0 when actual # of characters match NumberOfCharacters
int CLASS_LCM1602::expanderWrite(
int file,
char data,
int NumberOfCharacters) {
#ifdef DEBUG
//cout << "\033[1;31mint C_I2C::TestFunction(int a)\033[0m\n";
cout << "*** TRACE file " << __FILE__ << endl;
cout << " Enhanced function " << __FUNCTION__ << endl;
cout << " line " << __LINE__ << endl;
#endif
int NumberOfCharactersWritten;
// why NOBACKLIGHT during initialization - too fast to see anyway (?)
char buffer = data; // | LCD_BACKLIGHT;
//buffer = 0;
//while (1)
{
#ifdef DEBUG
cout << " buffer cast " << (static_cast<int>(buffer) & 0xFF) << endl;
cout << " buffer HEX cast " << hex << buffer << endl;
cout << " buffer + " << hex << +buffer << endl;
cout << " function " << __FUNCTION__ << endl;
cout << " line " << __LINE__ << endl;
#endif
//sleep(5);
}
// <b>NumberOfCharacters defaults to 1</b>
NumberOfCharactersWritten = write(file, &buffer, NumberOfCharacters);
// check characters written
if (NumberOfCharacters == NumberOfCharactersWritten) {
#ifdef DEBUG
cout << "Success NumberOfCharacters written " << NumberOfCharacters
<< endl;
#endif
//exit(1);
return 0;
} else {
cout << "\033[1;31mFailed expanderWrite\033[0m\n"; // failed
return -1;
}
}
</pre>
|
|
|
|
|
Vaclav_ wrote: ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED. Well that really encourages people to want to help you.
|
|
|
|
|
Vaclav_ wrote:
PLEASE - THE ATTACHED CODE IS WORK IN PROGRESS, REDUNDANT ETC , BUT IT WORKS!
ANY INAPPROPRIATE COMMENTS ON IT WILL BE IGNORED AND ARE NOT WELCOMED.
Hmm,
don't you mind such a "thesis" together with unformatted code looks like gross unrespect to guys you ask to help? 
|
|
|
|
|
You do it like with any write operation to a file descriptor by passing a buffer and it's size:
char buf[2];
buf[0] = data & 0x0f;
buf[1] = data >> 4;
write(file, buf, 2);
|
|
|
|
|
|
Hello,
My 64 bit (VS 2013)application is not running in debug mode. Output log is:
"'
MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120d.dll'. Cannot find or open the PDB file.
'MainApp.exe' (Win32): Unloaded 'C:\Windows\System32\msvcp120d.dll'
'MainApp.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120d.dll'. Cannot find or open the PDB file.
The thread 0x1bc8 has exited with code -1073741701 (0xc000007b).
The thread 0x2964 has exited with code -1073741701 (0xc000007b).
The thread 0x1040 has exited with code -1073741701 (0xc000007b).
The program '[9944] MainApp.exe' has exited with code -1073741701 (0xc000007b).
"
I tried to look over internet but could not find relevant answer. Can you please help to resolve it?
|
|
|
|
|
Check this: 0xc000007b error
They say that your settings or setup got messed up and:
Quote: I would suggest 2 things: first, try to reset your settings from Tools->import and export settings -> Reset all settings-> reset all settings, overwriting current settings.
If after that it still does not work, I would repair/re-install VS.
|
|
|
|
|
Did you by chance mixed some native and managed parameter options?
|
|
|
|
|
may be....where is this option?
|
|
|
|
|
Well, after re reading your OP I'm afraid I was wrong with my "hint".
It seems to more probable the reason is in a mixing some 32/64 bit settings or linked DLLs.
BTW, doe the Release 64 build work?
And Debug 32 build?
|
|
|
|
|
I am working on C++ project where performance is critical. there is no logging mechanism. I dont want to implement logging in the same project as it will hit performance. And hence I want to create A C# project while takes care of actually logging from C++ process I will push the Log strings to C# process to do Actually logging.
I want to know which is the best IPC - Named pipes ? Memory Mapped files ? Socket
Which should not hit the performance
Could you please point me to some sample code/link which has the mechanism to Log from C++ to C# code please
|
|
|
|
|
Logging will not be a performance issue if you do that in an own thread. That thread may be part of the application itself or another application.
Using another application with IPC makes it more complicated and requires that the other application is running. So I would not use another application if there is no need for other communications besides logging.
There might be even no need of using a thread when logging does not occur at high rates with large data. The log data has to be prepared anyway within the time critical thread. Using then a log file which stays open might be sufficient. If you are concerned about the file write times, use overlapped IO so that the writing is done by the system in the background (which is basically the same as suggested above: moving the operation to another thread).
I know that the above is not what you asked for but I think it is helpful and you might find out that using IPC is not necessary. When maximum performance is a must-have, you have to use one of the above mentioned methods (own thread or overlapped IO) anyway even with IPC.
|
|
|
|