|
Thanks.
Nishant S wrote:
p.s. I answered this in the newsgroup too (then saw this post and confirmed that you and he are the same )
Read that too. Andre claims it is a bug. It works with VB.NET without marking it as DefaultMember. I do not know when the MC++ team will have put a real working compiler for .NET - it is still too buggy
BTW, should it be DefaultMember or DefaultProperty?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Paul Selormey wrote:
Andre claims it is a bug
Well, I did not say it is a bug. All I said was that
a) As DefaultMember makes the property in question the indexer for C# (e.g. public string this[int index]{get; set;} ), there can be only one indexed property in C#
b) The way the indexer is accessed (instance[5] instead of what on expect for a indexed property instance.MyProp[5]) makes the class look array-like.
So, after all, it is not a missing feature in MC++ (which supports indexed properties), but more of a missing feature in the C# specifications.
(BTW. it is System.Reflection.DefaultMemberAttribute)
Best regards,
Andre
P.S.: damn, i hate it when I have to rewrite the whole post just because I forgot to log in
|
|
|
|
|
When compiling and linking a MC++ 2003 class library, the /EHsc compiler option causes a
LNK2001 error when a class is derived from a base class containing a destructor! Remove the
/EHsc option and the code compiles and links with any problems.
Create a MC++.NET 2003 Class Library with the following:
// bd.h
#pragma once
using namespace System;
namespace Testing
{
public __gc class Base
{
public:
Base(void)
{
Console::WriteLine(S"Base::Ctor");
}
~Base(void)
{
Console::WriteLine(S"Base::Dtor");
}
virtual void FromtheBase(void)
{
Console::WriteLine(S"Base::FromtheBase");
}
};
public __gc class Derived : public Base
{
public:
Derived(void)
{
Console::WriteLine(S"Derived::Ctor");
}
};
}
C++ Command Line:
/Od /AI "C:\Projects2003\Test\LinkError\Debug" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D
"_WINDLL" /FD /EHsc /MTd /GS /Yu"stdafx.h" /Fp"Debug/bd.pch" /Fo"Debug/"
/Fd"Debug/vc70.pdb" /W3 /nologo /c /Zi /clr /TP /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU
"C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
Additional Options: /Zl
Linker Command Line:
/OUT:"C:\Projects2003\Test\LinkError\Debug\bd.dll" /INCREMENTAL /NOLOGO /DLL /DEBUG
/ASSEMBLYDEBUG /PDB:"C:\Projects2003\Test\LinkError\Debug/bd.pdb" /FIXED:No nochkclr.obj
mscoree.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Program
Files\Microsoft Visual Studio .NET 2003\Sdk\v1.1\Lib\mscoree.lib"
Additional options: /noentry
Error:
bd error LNK2001: unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void
(__thiscall*)(void *),void *)" (?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)
After doing a link with the /FORCE option, I noticed the following in ildasm in the derived
class ctor:
.method public specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 32 (0x20)
.maxstack 2
IL_0000: ldarg.0
IL_0001: call instance void Testing.Base::.ctor()
.try
{
IL_0006: ldstr "Derived::Ctor"
IL_000b: call void [mscorlib]System.Console::WriteLine(string)
IL_0010: leave.s IL_001f
} // end .try
fault
{
IL_0012: ldftn instance void Testing.Base::__dtor()
IL_0018: ldarg.0
IL_0019: call void
modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) __CxxCallUnwindDtor(method
unmanaged thiscall void modopt([mscorlib]System.Runtime.CompilerServices.CallConvThiscall)
*(void*),
void*)
IL_001e: endfinally
} // end handler
IL_001f: ret
} // end of method Derived::.ctor
Since /NOENTRY is enabled, linkage to __CxxCallUnwindDtor and __DllMainCRTStartup@12 is
impossible. This leaves me with a some options while I wait for an answer from somebody:
1. Remove /EHsc with my fingers crossed. What are the side effects of doing this?
/EH{s|a}[c][-] specifies the model of exception handling to be used by the compiler
according to the Microsoft Visual C++.NET Language Reference.
2. Remove /NOENTRY and configure compile and link options like MC++ 2002. (Danger!)
3. Create a netmodule or assembly for the base class declaration to be reference by an assembly with the derived class declaration. (No way, more files to maintain)
4. Compile to .exe from .h and .cpp files. (very limiting, hard to maintain. Anti .NET!)
5. Mixed DLL Loading Problem Solution (Pain in the neck!)
Actually, I believe the solution deals with the disabling of /EHsc (/EHsc- or /GX-). /EHsc- is the default setting if you compile from the command line. You will need /EHsc only when you have unmanaged C++ unwinding exceptions. For example, if you use STL, /EHsc would be required, and the Mixed DLL Loading Problem solution applied.
|
|
|
|
|
Just turn it off for the "managed" files. And keep the rest as you want.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
I just installed Visual Studio .NET 2002 a few months ago. I am using the C++ compiler almost exclusively for ATL, MFC, WTL and managed C++ apps. Why should I upgrade to Visual Studio .Net 2003? What REAL benefits do I get. My company has already rejected the .Net framework for now... So I only use the C++ compiler. Is the upgrade worth it?
Robert Greene
|
|
|
|
|
I upgraded due to the following:
1. The upgrade costs less than $30.
2. VC++ 2003 conforms more closely with the standard.
3. MC++ has been enhanced.
Of course, with any new product, there will be bugs!
|
|
|
|
|
If you ever need to program in MC++, you must upgrade. The VS.NET 2002 is too buggy to use - you will have frustrated as many things do not work as expected.
Also, there are some startup wizards to quickly generate codes for you similar to C#. It comes with .NET 1.1, which you will have to work to get it to work with VS.NET 2002.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hi Robert... We should make this information more clear. All our messaging always seems to get lost... There are a significant number of changes in the C++ compiler from 7.1 to 7.0. There are things like P4/Athlon optimizations, SSE/SSE2 extension support, better whole program optimization (link-time optimizations), a better /GS switch and far, far, far better C++ conformance. If your a huge user of templates and use features like partial specialization and partial ordering, CL 7.1 is a huge win.
There are some benefits to the IDE also
Please checkout
http://msdn.microsoft.com/vstudio/
The upgrade is 29$ and you get a free pocketpc while supplies last
Albert Ho
.NET Developer Evangelist
Microsoft - Norcal
|
|
|
|
|
I'm writing data to a file and then wanting to run notepad.exe to display the data to the user.(Saves creating my own display medium) I've done it before in a Borland using SHELLEXECUTEINFO, and have been trying _exec** in VC++.Net without success.
Can someone point me in the right direction to what I should be using in the .Net environment please. i.e. what keywords should I be searching on.
Your help appreciated!
Regards,
Chris
|
|
|
|
|
WinExec ("notepad.exe",1);
rgds,
jhaga
|
|
|
|
|
Thanks for your help.
I tried it in my app, but it wouldn't compile, 'error C2065: 'WinExec' : Undeclared identifier.
I couldn't find it in my help either, so searching the MS website for WinExec led me to the following:
"The WinExec function runs the specified application.
Note This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function.
"
so I'll give the CreateProcess function a try.
|
|
|
|
|
You need to include this file
#include "windows.h"
jhaga
|
|
|
|
|
That will work but since he said MC++ app, I am assuming he wants to use MC++ to do it (i.e. managed code). The way to do this in managed code is to use the BCL class System::Diagnostics::Process class like this:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
I am losing some of the code with HTML formatting:
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int _tmain()
{
Process::Start("Notepad.exe");
return 0;
}
------------------------------
Sam Gentile
Microsoft .NET Consultant
•Web Site : http://www.samgentile.com/
•My O'Reilly Articles: http://www.oreillynet.com/pub/au/1070
• Read my .NET Web Blog! http://dotnetweblogs.com/sgentile/
• Come hear me speak at Win-Dev! http://butrain.bu.edu/windev/bios.asp
----------------------------
|
|
|
|
|
Hi All, wondering if someone could take a look at the below function and give me any clues as to why the output shows nothing.
I've passed through a sentence (no more than 100 characters) called sentence, which was input by the user. I'm trying to take each word, alphabetize it, and display the number of characters for each.
Thanks for any help!
<br />
void countOfChars(char sentence[]) <br />
{<br />
char *words = strtok(sentence," ");<br />
char *alphaArray[maxWords], *swap;<br />
int wordCount=0;<br />
<br />
cout << "\n\nWORD\t\t" << "Characters" << endl;<br />
<br />
while (words!=NULL) {<br />
wordCount++;<br />
words = strtok(NULL, " ");<br />
}<br />
alphaArray[wordCount] = words;
for (int i=0; i<wordCount-1; i++) {<br />
for (int j=0; j<wordCount-1; j++) {<br />
if (alphaArray[i] > alphaArray[i+1])<br />
swap = alphaArray[i+1];
alphaArray[i+1]=alphaArray[i];<br />
alphaArray[i]=swap;<br />
}}<br />
for (int x=0; x<wordCount; x++) { <br />
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;<br />
words = strtok(NULL, " ");<br />
}<br />
cout << endl;<br />
}<br />
Sheshi
|
|
|
|
|
// bubbelsort.cpp : Test use only
// Warning. Pointer handling, memory allocation and strtok() are bad
#include "string.h"
#include <iostream.h>
void countOfChars(char sentence[]) ;
int main(int argc, char* argv[])
{
const int buf_size = 1000;
char sName[buf_size]="a one a two";
//cout << "\n Enter max 50 words <each max 20 chars>:" << endl;
//cin.getline(sName, buf_size); // get the input line
countOfChars(sName);
}
void countOfChars(char sentence[])
{
char *words = strtok(sentence," ");
char *alphaArray[101]; // max 100 words
char *swap=NULL;
int wordCount=0;
while (words!=NULL) { // fill array
alphaArray[wordCount]=words;
wordCount++;
words = strtok(NULL, " ");
}
for (int i=0; i<wordCount; i++) { // bubbelsort the pointers
for (int j=i+1; j<wordCount; j++) {
if (*alphaArray[i]>*alphaArray[j])
{
swap=alphaArray[i];
alphaArray[i] = alphaArray[j];
alphaArray[j]=swap;
}
}
}
cout << "\n\nWORD\t\t" << "Characters" << endl; // display
for (int x=0; x <wordCount ; x++) {
cout << alphaArray[x] << "\t\t" << strlen(alphaArray[x]) << endl;
}
}
|
|
|
|
|
What is "this" pointer exactly?
Basil
|
|
|
|
|
a pointer to the class in context.
Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03
|
|
|
|
|
The this pointer is a pointer to the object its' self (that is secretly pass to a method/function).
Here are 2 examples that might help you understand:
Example using C:
//explicitly passing pointer to data object.
void func(struct structName* pData,int newID)
{
pData->ID = newID;
}
Example(s) using C++:
void func(int newID)
{
this->ID = newID;
}
OR
void func(int newID)
{
ID = newID; //"this->" is impiled if ID is member of class
}
Trust in the code Luke. Yea right!
|
|
|
|
|
Compiling i always receive the error message:
"DLLista::Component" no appropriate default constructor
what's wrong??
//DLLista.h
class DLLista : public Lista
{
public:
DLLista(Index n, BaseNode * V);
virtual ~DLLista();
class Component
{
public:
Component * next;
Component * prev;
BaseNode Element;
Component (BaseNode E);
};
};
//DLLista.cpp
DLLista::DLLista(Index n, BaseNode * V) : Lista(n, V){
};
DLLista::Component::Component(BaseNode E){
next=null;
prev=null;
Element=E;
};
DLLista::~DLLista(){};
//lista.h
class BaseNode
{
public:
BaseNode(){ indice = 0; };
private:
Index indice;
};
class Lista
{
public:
/* costruttore/distruttore */
Lista ( Index n, BaseNode * V );
~Lista();
}
|
|
|
|
|
Please avoid posting non-MC++ questions here. The code is full of arrangement problems. Also, there is nothing in "null" defined in C++. It should be "NULL"
Here is a simple rearranged codes which compiles successfully with VS.NET 2003, I am currently using:
typedef int Index;
class BaseNode
{
public:
BaseNode(){ indice = 0; };
private:
Index indice;
};
class Lista
{
public:
Lista ( Index n, BaseNode * V )
{
}
~Lista()
{
}
};
class DLLista : public Lista
{
public:
DLLista(Index n, BaseNode * V);
virtual ~DLLista();
class Component
{
public:
Component * next;
Component * prev;
BaseNode Element;
Component (BaseNode E);
};
};
DLLista::DLLista(Index n, BaseNode * V) : Lista(n, V){
};
DLLista::Component::Component(BaseNode E){
next=NULL;
prev=NULL;
Element=E;
};
DLLista::~DLLista(){};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Hello All,
Anyone got custom control toolbox icon/bitmap working and will like to share his/her experience. I need support not requiring direct loading from a file on a disk, but bitmap/icon in a resource.
It is very easy with VB.NET/C#
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I'm not sure if this will workin MC++, but it should (i know its C#):
namespace nBASS {
[ToolboxBitmap(typeof(nBASS.BASS), "nBASS.BASS.bmp")]
public class BASS : Component
{
The bitmap is named BASS.bmp and is an embedded resource, added via solution tab. Note the default namespace gets added automatically.
HTH
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Thanks.
I have being playing with something similar with success, may be I have to reexamine the implementation.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I didnt realise that adding managed resources was so difficult in a MC++ project. C# is such a breeze
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|