|
I've got unmanaged DLL that is being called from C# application using Interop. I need to step into native DLL function either from C# or debug native DLL and break at some break point.
I set up Enable unmanaged code debugging in C# console.
The DLL function is called correctly, e.g. it prints the message to console.
But as I run DLL with F5 and it invokes C# console, the break points do not work.
Nor can I step into DLL unmanaged code from C# console.
Чесноков
|
|
|
|
|
Dear all,
I have got some source codes where used lots of EXIT_SUCCESS and EXIT_FAILURE for return values. I knew these EXIT_SUCCESS and EXIT_FAILURE are defined in stdlib.h/cstdlib.h; however, I don't see the source including both of the header files.
Of course, the source may include a header which include stdlib.h/cstdlib.h.
My question is how I can find where exactly the stdlib.h/cstdlib.h have been included.
Thanks.
|
|
|
|
|
BTW, I am using Visual Studio 2005.
|
|
|
|
|
Set the "Generate Pre-Processed File" option (Project Properties->Configuration Properties->C/C++->Preprocessor) to "With Line Numbers (/P)" and examine the .i files that are generated. These will be annotated with '#line items that indicate the original file that code came from.
[edit]Look for stdlib.h and you can find what includes it. afx.h, as far as I can tell.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm looking for a method that mimics the functionality of fread without a file pointer. I want to read from a buffer into a buffer, for a number of bytes and move the pointer to the source buffer by the number of bytes returned - like fread.
Anyone done anything like this?
Thanks in advance
Jer 29:11
|
|
|
|
|
BYTE* pDest = <Destination Buffer>;
BYTE* pSrc = <Source Buffer>;
SIZE_T size = <Size to Read>;
MemoryRead(pDest, pSrc, size);
SIZE_T MemoryRead(BYTE* pDest, BYTE* pSrc, SIZE_T size)
{
CopyMemory(pDest, pSrc, size);
pSrc += size;
return size;
}
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Very cool and to the point. The key was to return the size - like fread.
Thanks much
Jer 29:11
|
|
|
|
|
I spoke too soon!
Actually, it doesn't quite work like fread. CopyMemory - defined as RtlCopyMemory needs size as an input. fread on the other hand returns the number of bytes read.
Thanks for responding but I still don't have the solution.
Jer 29:11
|
|
|
|
|
The reason is very clear. A file has an end and when you give a size, it will read either the mentioned size or till the end of the file. But a memory read either succeeds or fails.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
OK.
I just thought that there was a solution -perhaps you did too. I guess there's no way to do this
Jer 29:11
|
|
|
|
|
I use VC++9.0/VS2008. It seems template cannot work with operator. In Conversion Function, the operator's name cannot be or with template. Compiler probably doesn't have ability to deduce it. But the following code is really compilable in VC++6.0, which CString doesn't have template. Any suggestion? Thanks in advance!
Here is my code:
class TestString {
CString m_str;
public:
TestString(TCHAR* str):m_str(str) {}
operator CString() const {return m_str;}
};
int main(void)
{
TestString t1(_T("test1"));
TestString t2(_T("test2"));
CString strTest = t1 + t2;
return 0;
}
And Here is the error message:
1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Compiling...
1>Test.cpp
1>c:\build\test\test\test.cpp(19) : error C3767: '+': candidate function(s) not accessible
1> could be the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(653)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(664)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(675)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2034)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2043)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2052)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2061)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2071)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2081)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2091)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(653)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(664)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(675)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2034)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2043)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2052)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2061)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2071)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2081)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2091)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(653)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(664)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(675)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(653)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(664)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(675)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2034)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2043)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2052)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2061)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2071)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2081)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2091)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2034)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2043)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2052)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2061)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2071)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2081)' : '+' [may be found via argument-dependent lookup]
1> or the friend function at 'c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2091)' : '+' [may be found via argument-dependent lookup]
1>c:\build\test\test\test.cpp(19) : error C2676: binary '+' : 'TestString' does not define this operator or a conversion to a type acceptable to the predefined operator
1>Build log was saved at "file://c:\Build\Test\Test\Debug\BuildLog.htm"
1>Test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
modified on Tuesday, July 21, 2009 6:35 AM
|
|
|
|
|
The CString cast is not implicitly applied to the second operand.
You could do this -
TestString t1(_T("test1"));
TestString t2(_T("test2"));
CString strTest = t1;
strTest += t2;
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks for you reply. But, why second operand cannot be deduced out? and, why in VC6 it work fine? I've ever seen "At least one of the arguments must be of class type." from MSDN, here is the link:http://msdn.microsoft.com/en-us/library/czs2584d(VS.80).aspx[^], at the end of this article. Does this mean, there should be one argument with the right type?
|
|
|
|
|
The following code
CString strTest = t1 + t2;
translates to
CString strTest = CString(t1 + t2);
because you have defined the typecast to be an operator.
So here it is unable to do t1 + t2
So what you really need here is an overloaded operator + instead of operator CString
Try this -
operator CString() const {return m_str;}
CString operator + (const TestString& t2) { return m_str + t2.m_str; }
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
but, t1 and t2 can be convert to CString in advance, then call operator+ to concatenate them. and, how to explain it can work in vc6.0
|
|
|
|
|
When you give t1 + t2 the compiler doesn't know that it needs to convert it to CString .
What if you had another operator CMyString in your class.
What if you give t1 + t2 + t3 + t4 + t5 .
Does it work in VC++ 6.0?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
no operator like "CMyString". t1+t2+t3+t4+t5 does work in VC6.0, even t1 + "test" + t2 also can work. the only difference I know so far is that, CString in VC7 and later version is actually CStringT<...>. but in VC6, it's just CString without template. So, i guess the template is the root cause of such error.
|
|
|
|
|
This case is covered by section 14.6.5 of the C++ Standard. The CString operator+ is defined as a class-scope friend function of the underlying template class, CStringT . The rules of C++ mean that when compiling t1 + t2 , those friend functions of CStringT are invisible.
hawkgao0129 wrote: the following code is really compilable in VC++6.0
Which was really, really non-compliant with the standard...Them's the breaks!
The easiest solution is to add a suitable operator to your TestString class:
class TestString {
CString m_str;
public:
TestString(TCHAR* str):m_str(str) {}
operator CString() const {return m_str;}
<big>friend CString operator+(const TestString& t1, const TestString& t2) { return (CString)t1 + t2; }</big>
};
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I actually meant the ISO Standard, published in 1998 (which I bought for $18 in 2001 - a good buy, IMO) - that's the latest language level standard published. However, that working draft has (as far as I can tell) the same text for the section I referenced as the 1998 standard.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Yes
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
in addition, i also known why "CString strTest = t1 + (CString)t2;" can work fine in VC9. because of "Argument-Dependent Name (Koenig) Lookup", which was implemented after vs.net2003, operator+ can be looked up in CStringT. The real reason for that problem is, "Argument-Dependent Name Lookup" and "Conversion Functions" cannot work together. "Argument-Dependent Name Lookup" doesn't do type conversion for it's argument.
|
|
|
|
|
hawkgao0129 wrote: The real reason for that problem is, "Argument-Dependent Name Lookup" and "Conversion Functions" cannot work together
Not for *all* the function parameters no, because type conversions are taken into account only after the set of candidate overloads has been determined (which is when ADL (argument-dependent lookup) comes into play). However, if you look at the example you've shown, CString strTest = t1 + (CString)t2; , the operator is found through ADL. For it to be used, however, the first parameter has to be convertible from TestString to CString, which is performed using your user-defined conversion operator.
As I would imagine you're realising, the C++ name lookup rules are very complex
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
understood.
The whole story is: for t1+t2 case, at the very first, there is no operator+ with TestString argument list exists. Then, ADL is launched. ADL finds operator+ in CStringT may be the right choice. But, these are friend functions defined in CStringT, TestString doesn't have permission to access them.
for t1+(CString)t2 case, t2 has been converted to CStringT. As the rule of ADL, friend function operator+ can be accessed by CStringT itself. So, t1+(CString)t2 is legal.
Am I right?
|
|
|
|