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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 3mwn8tbfrd19ph0@mail.htl22.at

    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!
  • jacob navia

    #2
    Re: ow to prevent macro expansion in C/C++?

    3mwn8tbfrd19ph0 @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

    Comment

    • Gordon Burditt

      #3
      Re: 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
      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.


      Comment

      • Flash Gordon

        #4
        Re: ow to prevent macro expansion in C/C++?

        3mwn8tbfrd19ph0 @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

        Comment

        • CBFalconer

          #5
          Re: ow to prevent macro expansion in C/C++?

          Flash Gordon wrote:
          3mwn8tbfrd19ph0 @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 **

          Comment

          • Flash Gordon

            #6
            Re: ow to prevent macro expansion in C/C++?

            CBFalconer wrote, On 13/04/08 00:34:
            Flash Gordon wrote:
            >3mwn8tbfrd19ph0 @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

            Comment

            • Richard

              #7
              Re: ow to prevent macro expansion in C/C++?

              Flash Gordon <spam@flash-gordon.me.ukwri tes:
              CBFalconer wrote, On 13/04/08 00:34:
              >Flash Gordon wrote:
              >>3mwn8tbfrd19ph0 @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.

              Comment

              Working...