Answer Questions
Kamalkanth Nayak A native 'public class' or 'private class' in VC8
Specifying 'public class' or 'private class' for C++ class definitions is not part of the C++ standard. In a topic in the VS 2005 docs 'How to: Declare public and private on Native classes', it is suggested that this syntax is supported with VC8 for interaction with CLR ref classes and for specifying in a CLR assembly. However in the specific C++ language documentation for native classes, there is no mention of the possibility of prepending 'class' with either 'public' or 'private'. Furthermore where it is explained in the first topic above there is no explanation of what it actually means for native classes, other than the implied suggestion that it treats native classes like ref classes in CLR assemblies as regards ...Show All
prema.b strange linking error with operator overloading
Hello everyone, I am meeting with a strange linking error regarding to operator overloading. I am creating a C++ static lib, and then linking it with a C application. Here is the error message and source codes, I am using adapter.cpp, adapter.h, foo.cpp and foo.h to create a static lib called foo.lib, then link it with a C application (goo.c). There is no problem to generate the static lib foo.lib. Any comments to solve this link error error LNK2019: unresolved external symbol "private: class FooNameSpace::Foo __thiscall FooNameSpace::Foo::operator=(long)" ( 4Foo@FooNameSpace@@AAE AV01@J@Z ) referenced in function "private: __thiscall FooNameSpace::Foo::Foo( long)" ( 0Foo@FooNameSpace@@AAE@J@Z ) fatal error LNK1120: 1 ...Show All
Nguyen Duy Linh Private access
Say if we ve certain private methods along with private data members and public methods. other than friend function is thr any other way we access these members(they being private only) directly. its one of the requirements in a project of mine. The real prob comes when accessing function. say we've classes ported to us in .obj format. then going for DMA using pointers is a risky n unreliable job. class x { private: void meth1 ( ) { cout<< "Meth1" ; } void meth2 ( ) { cout<< "meth 2" ; } } ; class xduplicate { public: void virtual meth1 ( ) ; void virtual meth2 ( ) ; } ; main ( ) { x obj; xduplicate *obj1; obj1= ( xduplicate * ) &obj; obj1->meth1 ( ) ; ...Show All
kenlefeb Native C++ : Report on what the optimizer has done?
I've recently fixed a problem in my code where the optimizer "optimized out" a variable assignment, causing problems. The assignment happened in one module and any reading happens in other modules, my guess is the compiler thought the assignment was useless and discarded it. Is there any way to get a report on what the optimizer has found / changed after doing a compile/link If you can post the function that uses the the global variable where the assignment to it gets optimized away, then Microsoft can investigate this issue and come up with a fix in a future version. This is a necessary next step in getting closure on this issue. Also, if this is a local variable, then using the volatile ...Show All
Scott Royall VS2005 link error
I have a mixed mode managed and unmanaged C++ code which compiled, linked and ran fine in VS2003. However, this code does not link when using VS2005. It causes following link errors when I compile and link using /clr:oldsyntax switch, which I believe is necessary if using old Managed Extensions syntax. I am using STL string and map classes in my unmanaged code. I havea managed wrapper which delegates to unamanged methods which accept STL structures as parameters. I am convinced this is a compiler error in VS2005. Can someone please throw some light on this matter. Many Thanks A.obj : error LNK2020: unresolved token (0600001F) std.map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::bas ...Show All
nagual Pointer not working
When ever I try to compile the code below I get this error: " error C2102: '&' requires l-value " ICI is a pointer to an unmanaged class, this is being done with in a managed class. X is a double pointer, where as XPostion_Meters is just a double. ICI->ICOList[Count].X = &IPObs[Count]->IPObj->XPostion_Meters; Any help would be appreciated Can you please explain the meaning of a "unmanaged managed class" Are you positive that the error you are getting is actually from that line of code And if so, what's the definition of XPostion_Meters Yes, when I comment it out there are no problems. the definition: public interface class IPObje ...Show All
JFoushee Function pointers, pointers and references confusion
I'm struggling to get my head around this, I'm not entirely sure what is happening here. Wondering if someone could offer a detailed explanation as I can't find an answer elsewhere. In project InterfaceDLL which is a static lib although Interface.h does not make up part of the static lib. class DLLManager holds Interface * m_pInterface; in DLLManager.h. Interface is a struct in Interface.h declared in Interface.h not inside the struct and as extern "C":- bool GetInterface( Interface ** pInterface ); typedef bool ( *GETINTERFACE ) ( Interface ** pInterface ) Inside DLLManager.cpp in function LoadDLL() GETINTERFACE _GETINTERFACE; _GETINTERFACE = ( GETINTERFACE ) GetProcAddress( m_hDLL, "GetInterf ...Show All
Stefan Ghose stdio.h errors in Visual Studio 2005
I just finished installing VS 2005 (is it that hard for microsoft to just let people download like, a zip file of it, rather than an img file, which i had no idea what to do with at first ) and tried the following code: #include <stdio.h> // include the standard input/output header file void main(void) // our program starts here { printf("Hello World!"); // print "Hello World!" into the console return; // return void to windows } It was part of an origionally blank win32 console app called test. When i tried building the solution or compiling the file separately, I got all those errors: ------ Build started: Project: Test, Configuration: De ...Show All
Radexx console application entry point for al option main
I have another post concerning how to embed an xml file in the assembly. But this question is deeper within. Thought a new post is warranted. I can not determine the proper /main option setting for my console test application. (I have tried a variety and looked at ILDasm to no avail: main, assembly.main, console.main among others) Can someone supply the correct option setting. E:\VS8\TestStuff>al debug\TestStuff.exe /embed:productlist.xml /out:jkj.exe /target:exe /main:main Microsoft (R) Assembly Linker version 8.00.50727.42 for Microsoft (R) Windows (R) .NET Framework version 2.0.50727 Copyright (C) Microsoft Corporation 2001-2003. All rights reserved. ALINK: warning AL1020: Ignoring included assembly 'e:\VS8\TestStuff ...Show All
crazy_kebab Can a reference/managed class contain native/non-managed members?
I am trying to wrap up some native functions into a managed class wrapper. Some of these native functions use a FILE* as one of its parameters. For example, I might have a function like: void readWackyRecord(FILE *filePtr, char *buffer) This function will read a record from a file pointed at by filePtr and return the record in the character buffer to the user. I was thinking of enclosing this function into a managed class called FileUtilities like so: public ref class FileUtilities { private: FILE *m_fp; String ^m_filename; public: FileUtilities(String ^filename); void WReadWackyRecord(String ^%buffer); } To use the new function, you first must instantiate an object of cl ...Show All
Sledgehammer Difference between PWSTR, LPSTR, char, WCHAR
Hi all, Can anyone tell me the difference between all this datatypes PWSTR, LPSTR, WCHAR, char, LPCSTR Also i have a code in which i am not able to understand the error which is related to above data types LSA_UNICODE_STRING lsastrPrivs[1]={0}; lsastrPrivs[0].Buffer = SE_TCB_NAME; lsastrPrivs[0].Length = lstrlen(lsastrPrivs[0].Buffer)* sizeof (WCHAR); lsastrPrivs[0].MaximumLength = lsastrPrivs[0].Length + sizeof (WCHAR); NTSTATUS ntstatus = LsaAddAccountRights(hPolicy,pSid,lsastrPrivs,1); ULONG lErr1 = LsaNtStatusToWinError(ntstatus); cout<<lErr1<<endl; Now when i run this code, it gives following errors error C2440: '=' : cannot convert from 'const char [15]' to 'PWSTR' (for line 2) err ...Show All
RomanQ How to access a program ported from C from other .net project?
Hi, I am pretty new to C++ .Net and I need help on how to let my .Net programs accessing functions ported from a C program. What I have now is a solution that contains two projects. The first is a C++ .Net class library project and the second is a VB.Net project (doesn't have to be VB, it can be any other .net languages). What I need is to have the VB test program call functions from the C++ program. The C++ project is created by porting an existing C program. What I did was that I created a class library project using the C++ wizard. Then I added my existing C program (without any change at all), MyLib.c, into the project and removed all those generated files that I don't need. After fixing some issues, now I have the project co ...Show All
Phil Bolduc Removing ext from filename
In a C++/CLI (vs2005) app, I've a String which contains a filename, e.g. "test.txt". How do I remove the file extension ".txt", such that, the resulting string is "test". I can't get TrimEnd to remove the extension ".txt" in the following code. Does anyone know why String^ temp = "abcb.txt" ; String^ temp2 = temp->TrimEnd( '.' ); temp2 stills store "abcd.txt". Hi , following snippets will do ur job 1) array <String^> ^strings = temp->Split( '.' ,2); strings[0] will cotain 'test' 2) int nPos = temp->LastIndexOf( '.' ); String^ part = temp->Substri ...Show All
enric vives QueryInterface return E_NOINTERFACE when executing in native code and called through managed wrapper
(Environment: WinXP, Visual Studio 2005) The structure of my sample program is listed as follows: 1. Create a native COM component Fun, with interface IFun;(ATL project) 2. Create a native c++ class using this COM component(Win32 application and build to a dll file) class CSample{ private: IFun* m_pFun; public: void Initialize(){ ... IUnknown* pUnk; hr = ::CoCreateInstance( CLSID_Fun, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID*)&pUnk); hr = pUnk->QueryInterface( IID_IFun, (LPVOID*)&m_pFun);...} ...}; 3. managed Wrapper for nat ...Show All
Peter Peter http.h problem
I have a problem. I'm noob and my program is: You need to add the library Httpapi.lib to the linker setting or to include the follwoing line into you code: #pragma comment ( lib , "httpapi.lib") ...Show All
