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

  • SEARCH
  • Home
  • 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 7772609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:55:34+00:00 2026-06-01T16:55:34+00:00

If I write something like #define INT_PTR int* INT_PTR ptr4, ptr5, ptr6; In this

  • 0

If I write something like

#define INT_PTR int*
INT_PTR ptr4, ptr5, ptr6;

In this case only ptr4 is pointer to an integer, rest of the values (ptr5 and ptr6) are integers. How they are taking the integer value ? Either it should give some compilation error.

Why is it this way that compiler is treating ptr5 and ptr6 as integers.

  • 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-06-01T16:55:35+00:00Added an answer on June 1, 2026 at 4:55 pm

    This actually has nothing to do with the #define, which is simply a textual replacement.

    After the preprocessor phase (when the substitution takes place), you end up with:

    int* ptr4, ptr5, ptr6;
    

    and, because the * binds to the variable rather than the type, you create one integer pointer and two integers.

    This is why I prefer to write:

    int *xyzzy;
    

    rather than:

    int* xyzzy;
    

    since the former makes it clearer that the * belongs to the variable. If you want to define a new type in C, the command is, surprisingly enough, typedef 🙂

    typedef int * INTPTR;
    INTPTR ptr4, ptr5, ptr6;
    

    That defines a new type that will apply to all variables that follow it, rather than just substituting text, as per the macro. In other words, the type INTPTR (int *) applies to all three of ptr4, ptr5 and ptr6.

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

Sidebar

Related Questions

I occasionally write code something like this: // file1.cpp #define DO_THIS 1 #if DO_THIS
I have something like this: #define QUIT_TIME 5 int main(int argc, char **argv) {
I would ideally like to write something like this: myValue1 = 1 :: Int
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
If I write something like this: var img = $(new Image()).attr('src', image.src); How can
I usually write something like this: <mx:VBox height=100% width=155> <mx:Button label=b1 width=100%/> <mx:Buttonlabel=b2 width=100%/>
I want to write something like: var list = new List<int>(){1,2,3}; var bigList =
I have something like this: #include <iostream> namespace N { typedef std::pair<int, double> MyPair;
I want to write something like Skype, i.e. I have a constant audio stream
In C# I'd write something like MyType arr = new MyType[10]; to alloc arr

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.