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 8978261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:34:05+00:00 2026-06-15T19:34:05+00:00

gcc (GCC) 4.7.2 c89 Hello, I have been looking at a test suite and

  • 0
gcc (GCC) 4.7.2
c89

Hello,

I have been looking at a test suite and I noticed this function-like macro declared like this:

#define MU_SUITE_START() char *msg = NULL

However, is there any real difference to doing just this instead:

#define MU_SUITE_START char *msg = NULL

Macros just do text replacement so I don’t think there is going to be any performance issues.

Using cpp I get the following results so nothing special here.

function-like macro

char *msg = __null;

marco

char *msg = __null;

Just a side note: Is it worth declaring a function-like marco that doesn’t provide in input parameters?
Here I am not passing any parameters
i.e.

#define PRINT_MSG() printf("This is the message\n")

Why bother with the function-like macro if there are no input parameters, isn’t this better?

#define PRINT_MSG printf("This is the message\n")

Many thanks for any suggestions,

  • 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-15T19:34:07+00:00Added an answer on June 15, 2026 at 7:34 pm

    There’s one difference between the object-like and function-like macros:

    #define OBJECT     char *msg1 = NULL
    #define FUNCTION() char *msg2 = NULL
    
    void somefunc(void)
    {
        int OBJECT = 5;
        int FUNCTION = 10;
        ...
    }
    

    The declaration for OBJECT is replaced by the macro (so the code won’t compile), but the reference to FUNCTION is not a macro invocation because it is not followed by an open parenthesis.

    This is seldom important. However, when it is, it really matters.

    A more typical case might be a function that can be implemented as a macro. For sake of discussion (because it is easily understood rather than because it is a good example):

    extern int isdigit(int c);
    #define isdigit(c) ((c) >= '0' && (c) <= '9')
    

    and in an implementation file:

    int (isdigit)(int c)
    {
        assert((c >= 0 && c <= UCHAR_MAX) || c == EOF);
        return isdigit(c);
    }
    

    Ignoring little details like that isn’t how isdigit() is likely to be implemented, and a macro implementation of isdigit() is not allowed to evaluate its argument more than once, and you aren’t supposed to redefine things that are in the standard C library, the function definition is not macro expanded because the name isdigit is not followed by (, but the macro inside the function is expanded. At least the function is implemented in terms of the macro, which pretty much guarantees the same behaviour.

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

Sidebar

Related Questions

gcc (GCC) 4.6.0 c89 I have a signal handler declared like this: /* Setup
Possible Duplicate: Should a function have only one return statement? Hello, gcc 4.4.4 c89
gcc 4.7.2 c89 Hello, I have the following function: void module_param_destroy(module_param_t *param) { param
gcc (GCC) 4.6.3 c89 Hello, I am just wondering if this is the best
gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
c89 gcc 4.7.4 I was just experimenting with macros like these: #define LOG_INFO_1(fmt, ...)
gcc 4.4.4 c89 I have this in my header file. port.h struct struct_tag; int
gcc (GCC) 4.7.0 c89 Hello, I have trying to save a database of rows
gcc (GCC) 4.7.0 c89 Hello, I have the following structure that I am trying
c89 gcc (GCC) 4.7.2 Hello, I am looking at some string functions as I

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.