How to prevent macro expansion in C/C++

3

3mwn8tbfrd19ph0

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!
 
P

peter koch

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!

This is one of the reasons that I prefer to stay away from Microsoft
naming conventions. If I were you, I believe that I would simply
include windows.h in your headerfile. It is a hack, but the
alternative would be to change your naming convention and that
probably is to late.

/Peter

PS: I believe you meant CreateFont where you wrote CreateFile or vice
versa.
 
K

kepeng

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

before you use it.
 
J

James Kanze

* (e-mail address removed)22.at:
Name the function createFile, and for your own functions,
don't use leading uppercase names.

I agree, but what about class names? (Or what about the case
where the local coding convention requires upper case names for
functions. It's a convention that I don't like, but it seems to
be fairly frequent.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top