Weird errors - C and C++

Hi all,

Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK

I’ve got a weird problem, that I was hoping someone might have some input on. I’ve got a disk class driver that I’ve been building, and during compiling I kept getting an “LNK2001: unresolved external _DriverEntry@8”. After a bit of debugging, I cut my program down to the bare bones, and it came down to the fact that my DriverEntry() was in a .Cpp file, instead of a .c file. After renaming the file to .c, the program compiled, but then when I added a few classes into the app, it failed to build, complaining about keyword: class, public, private. It seems odd to me that C++ is not supported, and figured it’s got to be some small setting i’ve missed. Anyone have some pointers on what I can do to resolve this?

Thanks,

Matt.


Sign-up for your own FREE Personalized E-mail at Mail.com

http://www.mail.com/?sr=signup

Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.

http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59

Keep your .cpp extension and declare your DriverEntry routine as ‘extern “C”’. You will probably need to enclose the DDK includes in ‘extern “C” {}’ as well.

Aaron Stavens
NetMotion Wireless, Inc.

-----Original Message-----
From: Matt Lynch [mailto:xxxxx@earthling.net]
Sent: Tuesday, August 06, 2002 6:01 PM
To: File Systems Developers
Subject: [ntfsd] Weird errors - C and C++

Hi all,

Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK

I’ve got a weird problem, that I was hoping someone might have some input on. I’ve got a disk class driver that I’ve been building, and during compiling I kept getting an “LNK2001: unresolved external _DriverEntry@8”. After a bit of debugging, I cut my program down to the bare bones, and it came down to the fact that my DriverEntry() was in a .Cpp file, instead of a .c file. After renaming the file to .c, the program compiled, but then when I added a few classes into the app, it failed to build, complaining about keyword: class, public, private. It seems odd to me that C++ is not supported, and figured it’s got to be some small setting i’ve missed. Anyone have some pointers on what I can do to resolve this?

Thanks,

Matt.


Sign-up for your own FREE Personalized E-mail at Mail.com

http://www.mail.com/?sr=signup

Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.

http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59


You are currently subscribed to ntfsd as: xxxxx@nmwco.com
To unsubscribe send a blank email to %%email.unsub%%

The C++ compiler “mangles” the exported name, imbedding parameter
information, etc, so “_DriverEntry@8” becomes something very different
like “DriverEntry$SOMESTRINGOFCHARACTERS”.

Add ‘extern"C"’ to any functions that need to be exposed, such as
DriverEntry(). Change:

NTSTATUS DriverEntry( …, … )

to

extern “C” NTSTATUS DriverEntry( …, … ).

You should also wrap extern “C” around header files. The declaration
CPLUSPLUS is automatically defined for cpp files.

#ifdef CPLUSPLUS
extern “C”
{
#endif

#include
#include
#include

#ifdef CPLUSPLUS
}
#endif

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Matt Lynch [mailto:xxxxx@earthling.net]
Sent: Tuesday, August 06, 2002 6:01 PM
To: File Systems Developers
Subject: [ntfsd] Weird errors - C and C++

Hi all,

Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK

I’ve got a weird problem, that I was hoping someone might have some
input on. I’ve got a disk class driver that I’ve been building, and
during compiling I kept getting an “LNK2001: unresolved external
_DriverEntry@8”. After a bit of debugging, I cut my program down to the
bare bones, and it came down to the fact that my DriverEntry() was in a
.Cpp file, instead of a .c file. After renaming the file to .c, the
program compiled, but then when I added a few classes into the app, it
failed to build, complaining about keyword: class, public, private. It
seems odd to me that C++ is not supported, and figured it’s got to be
some small setting i’ve missed. Anyone have some pointers on what I can
do to resolve this?

Thanks,

Matt.


Sign-up for your own FREE Personalized E-mail at Mail.com

http://www.mail.com/?sr=signup

Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.

http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59


You are currently subscribed to ntfsd as: xxxxx@microsoft.com
To unsubscribe send a blank email to %%email.unsub%%

You need DriverWorks from Compuware Numega because it provides the C++
framework needed.

----- Original Message -----
From: “Matt Lynch”
To: “File Systems Developers”
Sent: Tuesday, August 06, 2002 9:00 PM
Subject: [ntfsd] Weird errors - C and C++

> Hi all,
>
> Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK
>
> I’ve got a weird problem, that I was hoping someone might have some
input on. I’ve got a disk class driver that I’ve been building, and during
compiling I kept getting an “LNK2001: unresolved external _DriverEntry@8”.
After a bit of debugging, I cut my program down to the bare bones, and it
came down to the fact that my DriverEntry() was in a .Cpp file, instead of a
.c file. After renaming the file to .c, the program compiled, but then when
I added a few classes into the app, it failed to build, complaining about
keyword: class, public, private. It seems odd to me that C++ is not
supported, and figured it’s got to be some small setting i’ve missed.
Anyone have some pointers on what I can do to resolve this?
>
> Thanks,
>
>
> Matt.
> –
> __________________________________________________________
>
> Sign-up for your own FREE Personalized E-mail at Mail.com
>
> http://www.mail.com/?sr=signup
>
>
>
> Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.
>
> http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to %%email.unsub%%

I figured that if he didn’t know about that and C++ it would be better to
use something like DriverWorks which provides replacements for new/delete,
etc. I have used it for years and like it much better than just straight C.

----- Original Message -----
From: “Bryan Burgin”
To: “File Systems Developers”
Cc:
Sent: Tuesday, August 06, 2002 9:51 PM
Subject: [ntfsd] RE: Weird errors - C and C++

The C++ compiler “mangles” the exported name, imbedding parameter
information, etc, so “_DriverEntry@8” becomes something very different
like “DriverEntry$SOMESTRINGOFCHARACTERS”.

Add ‘extern"C"’ to any functions that need to be exposed, such as
DriverEntry(). Change:

NTSTATUS DriverEntry( …, … )

to

extern “C” NTSTATUS DriverEntry( …, … ).

You should also wrap extern “C” around header files. The declaration
CPLUSPLUS is automatically defined for cpp files.

#ifdef CPLUSPLUS
extern “C”
{
#endif

#include
#include
#include

#ifdef CPLUSPLUS
}
#endif

Bryan S. Burgin
xxxxx@microsoft.com

This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: Matt Lynch [mailto:xxxxx@earthling.net]
Sent: Tuesday, August 06, 2002 6:01 PM
To: File Systems Developers
Subject: [ntfsd] Weird errors - C and C++

Hi all,

Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK

I’ve got a weird problem, that I was hoping someone might have some
input on. I’ve got a disk class driver that I’ve been building, and
during compiling I kept getting an “LNK2001: unresolved external
_DriverEntry@8”. After a bit of debugging, I cut my program down to the
bare bones, and it came down to the fact that my DriverEntry() was in a
.Cpp file, instead of a .c file. After renaming the file to .c, the
program compiled, but then when I added a few classes into the app, it
failed to build, complaining about keyword: class, public, private. It
seems odd to me that C++ is not supported, and figured it’s got to be
some small setting i’ve missed. Anyone have some pointers on what I can
do to resolve this?

Thanks,

Matt.

__________________________________________________________

Sign-up for your own FREE Personalized E-mail at Mail.com

http://www.mail.com/?sr=signup

Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.

http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59


You are currently subscribed to ntfsd as: xxxxx@microsoft.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@yoshimuni.com
To unsubscribe send a blank email to %%email.unsub%%

Thanks heaps for that,
It was driving me crackers. I thought it would be something small.

Cheers,

Matt

“David J. Craig” wrote in message
news:xxxxx@ntfsd…
>
> etc. I have used it for years and like it much better than just straight
C.
>

Sigh! And to think I had such respect for you… Then again, I guess
everyone’s entitled to one or two private peccadillos,

:wink:

P

I am not a big user of C++ features, but the Microsoft compiler gives better
syntax and logic checking when doing C++ at warning level 4 than it does
with C. I have seen cases when using C++ was a major advantage. The old
FlashPath drivers had to be written for SmartMedia, Memory Stick, and MMC/SD
card. By using a FlashMemory pure virtual class the various subclasses were
much easier to fit in and we could build for any much easier. It was
possible to create a driver that could have worked for any in a single but
since the various technologies came from different companies, it was never
done.

I am not fond of cramming all the C++ OOP features that exist into a driver,
and for the first time someone tries this, I would suggest they just do
straight C code, but name the file extension as .cpp. It will make you
clean up all undefined prototypes as a minimum.

----- Original Message -----
From: “Peter Viscarola”
Newsgroups: ntfsd
To: “File Systems Developers”
Sent: Wednesday, August 07, 2002 10:55 AM
Subject: [ntfsd] Re: Weird errors - C and C++

>
> “David J. Craig” wrote in message
> news:xxxxx@ntfsd…
> >
> > etc. I have used it for years and like it much better than just
straight
> C.
> >
>
> Sigh! And to think I had such respect for you… Then again, I guess
> everyone’s entitled to one or two private peccadillos,
>
> :wink:
>
> P
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to %%email.unsub%%

“David J. Craig” wrote in message
news:xxxxx@ntfsd…
>
> and for the first time someone tries this, I would suggest they just do
> straight C code, but name the file extension as .cpp. It will make you
> clean up all undefined prototypes as a minimum.
>

I agree 100% – The C++ compiler does much nicer error checking; We
actually recommend using it in our “getting started” FAQ.

Peter
OSR

You want to enclose the DriverEntry prototype definition in the .CPP
file in an: extern “C” { }
parentheses, to inhibit the C++ name mangling .
Ravi

-----Original Message-----
From: Matt Lynch [mailto:xxxxx@earthling.net]
Sent: Tuesday, August 06, 2002 6:01 PM
To: File Systems Developers
Subject: [ntfsd] Weird errors - C and C++

Hi all,

Platform: VC++ 6.0, SP5, Win2k Pro Sp3, Win2k DDK

I’ve got a weird problem, that I was hoping someone might have some
input on. I’ve got a disk class driver that I’ve been building, and
during compiling I kept getting an “LNK2001: unresolved external
_DriverEntry@8”. After a bit of debugging, I cut my program down to the
bare bones, and it came down to the fact that my DriverEntry() was in a
.Cpp file, instead of a .c file. After renaming the file to .c, the
program compiled, but then when I added a few classes into the app, it
failed to build, complaining about keyword: class, public, private. It
seems odd to me that C++ is not supported, and figured it’s got to be
some small setting i’ve missed. Anyone have some pointers on what I can
do to resolve this?

Thanks,

Matt.


Sign-up for your own FREE Personalized E-mail at Mail.com

http://www.mail.com/?sr=signup

Get 4 DVDs for $.49 cents! plus shipping & processing. Click to join.

http://adfarm.mediaplex.com/ad/ck/990-1736-3566-59


You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to %%email.unsub%%