468,249 Members | 1,509 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

ow to prevent macro expansion in C/C++?

I am writing codes in windows and Unicode. The windows header file
defines CreateFont into CreateFontW. I am using a class which has a
function CreateFile. So when compiling, I got error that the
CreateFontW is not a member of the class.

What should I do?

Thanks for your help!
Jun 27 '08 #1
6 2055
3m*************@mail.htl22.at wrote:
I am writing codes in windows and Unicode. The windows header file
defines CreateFont into CreateFontW. I am using a class which has a
function CreateFile. So when compiling, I got error that the
CreateFontW is not a member of the class.

What should I do?

Thanks for your help!
#undef CreateFont

and you are all set
Jun 27 '08 #2
>I am writing codes in windows and Unicode. The windows header file
>defines CreateFont into CreateFontW. I am using a class which has a
C does not have classes.
>function CreateFile. So when compiling, I got error that the
CreateFontW is not a member of the class.
Huh? How did Create*File* get turned into Create*Font*W?
I think there are either typos in your post or something else
going on you haven't mentioned.
>What should I do?
Can you rename the member functions of your class?

It looks like you can't include the Windows header file and the
class header file in the same compilation. Can you split the code
into separate files?

One of the reason ANSI C has "namespace pollution" rules on ANSI C
header files is to avoid this sort of thing. It doesn't have any
jurisdiction over OS headers, though.
Jun 27 '08 #3
3m*************@mail.htl22.at wrote, On 12/04/08 21:52:
I am writing codes in windows and Unicode. The windows header file
defines CreateFont into CreateFontW. I am using a class which has a
function CreateFile. So when compiling, I got error that the
CreateFontW is not a member of the class.

What should I do?
You should learn that C and C++ are different languages which is why
there is also a group comp.lang.c++. C does not have classes, so if you
are getting errors about something not being a member of a class you are
almost certainly not using C.

Also, I strongly suspect that the things you are talking about are
Windows specific (I happen to know that Windows has a CreateFile
function) so you actually need to ask in a Windows group where you will
find a lot more Windows experts.
--
Flash Gordon
Jun 27 '08 #4
Flash Gordon wrote:
3m*************@mail.htl22.at wrote:
>I am writing codes in windows and Unicode. The windows header
file defines CreateFont into CreateFontW. I am using a class
which has a function CreateFile. So when compiling, I got error
that the CreateFontW is not a member of the class.

What should I do?

You should learn that C and C++ are different languages which is
why there is also a group comp.lang.c++. C does not have classes,
so if you are getting errors about something not being a member
of a class you are almost certainly not using C.

Also, I strongly suspect that the things you are talking about
are Windows specific (I happen to know that Windows has a
CreateFile function) so you actually need to ask in a Windows
group where you will find a lot more Windows experts.
In fact, CreateFont and CreateFontW do not exist in the standard C
language, and thus are entirely off-topic in this newsgroup. If
you are willing to put up with the non-standard Windows system, you
should ask your questions in a Windows newsgroup.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.

** Posted from http://www.teranews.com **
Jun 27 '08 #5
CBFalconer wrote, On 13/04/08 00:34:
Flash Gordon wrote:
>3m*************@mail.htl22.at wrote:
>>I am writing codes in windows and Unicode. The windows header
file defines CreateFont into CreateFontW. I am using a class
which has a function CreateFile. So when compiling, I got error
that the CreateFontW is not a member of the class.

What should I do?
You should learn that C and C++ are different languages which is
why there is also a group comp.lang.c++. C does not have classes,
so if you are getting errors about something not being a member
of a class you are almost certainly not using C.

Also, I strongly suspect that the things you are talking about
are Windows specific (I happen to know that Windows has a
CreateFile function) so you actually need to ask in a Windows
group where you will find a lot more Windows experts.

In fact, CreateFont and CreateFontW do not exist in the standard C
language, and thus are entirely off-topic in this newsgroup. If
you are willing to put up with the non-standard Windows system, you
should ask your questions in a Windows newsgroup.
Why bother posting to restate that the poster should go to a Windows
group when I had already said that? Also C (of any variety) is
irrelevant to the OPs problem as you will find if you re-read the above
since the OP is using C++.
--
Flash Gordon
Jun 27 '08 #6
Flash Gordon <sp**@flash-gordon.me.ukwrites:
CBFalconer wrote, On 13/04/08 00:34:
>Flash Gordon wrote:
>>3m*************@mail.htl22.at wrote:

I am writing codes in windows and Unicode. The windows header
file defines CreateFont into CreateFontW. I am using a class
which has a function CreateFile. So when compiling, I got error
that the CreateFontW is not a member of the class.

What should I do?
You should learn that C and C++ are different languages which is
why there is also a group comp.lang.c++. C does not have classes,
so if you are getting errors about something not being a member
of a class you are almost certainly not using C.

Also, I strongly suspect that the things you are talking about
are Windows specific (I happen to know that Windows has a
CreateFile function) so you actually need to ask in a Windows
group where you will find a lot more Windows experts.

In fact, CreateFont and CreateFontW do not exist in the standard C
language, and thus are entirely off-topic in this newsgroup. If
you are willing to put up with the non-standard Windows system, you
should ask your questions in a Windows newsgroup.

Why bother posting to restate that the poster should go to a Windows
group when I had already said that? Also C (of any variety) is
It has never stopped you "Flash" - I counted 8 "OT" replies once where
you were about #5. I remember chuckling at how pleased you must all have
been to get a chance to bully another newcomer to the group.

Another case of the one rule for some and other rules for others? I had
no idea that Chuck was so far gone from the clique.
irrelevant to the OPs problem as you will find if you re-read the
above since the OP is using C++.
Chuck is scraping the bottom of the barrel to find things he is
qualified to reply to without making a mistake.
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

25 posts views Thread by Andrew Dalke | last post: by
699 posts views Thread by mike420 | last post: by
3 posts views Thread by John | last post: by
10 posts views Thread by Karim Thapa | last post: by
5 posts views Thread by Patrick Kowalzick | last post: by
2 posts views Thread by talkaboutquality | last post: by
5 posts views Thread by Francois Grieu | last post: by
16 posts views Thread by mdh | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.