Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:58:32+00:00 2026-05-27T14:58:32+00:00

I have a class that has a member function called SendMessage . No member

  • 0

I have a class that has a member function called SendMessage. No member function named SendMessageA exists in the project.
Project is multibite, so I have a define

#define SendMessage SendMessageA

If I call SendMessage somewhere in that class, will my project call SendMessage or SendMessageA ?

If the replace is made by preprocessor,the project should not compile. Right ?
But I see in a dump that SendMessageA is called … end eip register is not in any VAD

EDIT

A more specific question: is preprocessor blindly replace the defines ? or first checks for a match in the class ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:58:33+00:00Added an answer on May 27, 2026 at 2:58 pm

    How C++ preprocessor works

    In case of #define A B preprocessor replaces ALL occurences of A with B. It is pure substitution.

    Will my project call SendMessage or SendMessageA ?

    Your project will call either SendMessageA or SendMessageW – depending on whether it was compiled with unicode support or not. There’s no SendMessage function – it doesn’t exist.

    f the replace is made the project should not compile.

    SendMessageA is declared within <widnows.h> (or in a header that is included from windows.h) – somewhere, and its linking info is within one of base system libraries (User32.lib, I think). If you’re on windows, there’s a very good chance <windows.h> is #included from somewhere, and corresponding *.lib is already in linker dependencies.

    –EDIT–

    A more specific question: is preprocessor blindly replace the defines ?

    Yes, preprocessor blindly replaces defines. For non-blind replacement you have templates, but they have their own limitations. Some thing that can be done with preprocessor cannot be done with templates and vice versa. Preprocessor have stringize operator, templates have type-checking and metaprogramming.

    My problem is why sometimes the member function SendMessage is called because the code works (most of the time)

    If you have SendMessage method in your code (BAD idea on windows platform – clashes with system macro, replace with sendMessage() or use different name, because even namespaces won’t help you to avoid omnipresent preprocessor) your method (not SendMessageA/SendMessageW) will be called from *.cpp ONLY if <windows.h> was not included in that *.cpp.

    Compiler operates at one file at a time, and has no knowledge of thing that go on in other files, so if there’s no <windows.h> #included, your method will be called, because preprocessor won’t have any knowledge about SendMessage #define (from <windows.h>). If <windows.h> is included, then ALL occurences of SendMessage will be replaced with SendMessageA/SendMessageW, because preprocessor does its job first.

    One possible solution in your situation would be to avoid using naming convention similar to the one in Win API. I.e. make sure that function names don’t start with capital letter. That’ll solve many problems, but you’ll still get minor trouble from min/max macros.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a member function in a class that has a callback, but the
Let's say I have a class that has a member called data which is
I have a template class that has a template member function that needs to
Let's say I have a simple class called WebsterDictionary that has a function that
So I have a class that has the following member variables. I have get
I have a base class that has a private static member: class Base {
I have a base class with a templated function that has the general templated
I have a class that has a Generic type G In my class model
I have a class that has some properties. And I want something that calculates
I have a class that has a vector of another class objects as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.