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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:43:12+00:00 2026-05-26T01:43:12+00:00

Please see my code: #include <stdint.h> int main(int argc, char *argv[]) { unsigned char

  • 0

Please see my code:

#include <stdint.h>

int main(int argc, char *argv[])
{
unsigned char s = 0xffU;
char ch = 0xff;
int val = 78;
((int8_t) + (78)); /*what does this mean*/

INT8_C(val);    /*equivalent to above*/

signed char + 78; /*not allowed*/

return 0;
}

I find that the macro definition in <stdint.h> is:

#define INT8_C(val) ((int8_t) + (val))

What is the meaning or significance of this plus sign?

  • 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-26T01:43:13+00:00Added an answer on May 26, 2026 at 1:43 am

    The snippet:

    ((int8_t) + (78));
    

    is an expression, one that takes the value 78, applies the unary +, then casts that to an int8_t type, before throwing it away. It is no real different to the legal expressions:

    42;
    a + 1;
    

    which also evaluate the expressions then throw away the result (though these will possibly be optimised out of existence if the compiler can tell that there are no side effects).

    These “naked” expressions are perfectly valid in C and generally useful only when they have side effects, such as with i++, which calculates i and throws it away with the side effect being that it increments the value.

    The way you should be using that macro is more along the lines of:

    int8_t varname = INT8_C (somevalue);
    

    The reason for the seemingly redundant unary + operator can be found in the standard. Quoting C99 6.5.3.3 Unary arithmetic operators /1:

    The operand of the unary + or – operator shall have arithmetic type;

    And, in 6.2.5 Types, /18:

    Integer and floating types are collectively called arithmetic types.

    In other words, the unary + prevents you from using all the other data types in the macro, such as pointers, complex numbers or structures.

    And, finally, the reason your:

    signed char + 78;
    

    snippet doesn’t work is because it’s not the same thing. This one is starting to declare a variable of type signed char but chokes when it gets to the + since that’s not a legal variable name. To make it equivalent to your working snippet, you would use:

    (signed char) + 78;
    

    which is the casting of the value +78 to type signed char.

    And, as per C99 7.8.14 Macros for integer constants /2, you should also be careful with using non-constants in those macros, they’re not guaranteed to work:

    The argument in any instance of these macros shall be an unsuffixed integer constant (as
    defined in 6.4.4.1) with a value that does not exceed the limits for the corresponding type.

    6.4.4.1 simply specifies the various integer formats (decimal/octal/hex) with the various suffixes (U, UL, ULL, L, LL and the lower-case equivalents, depending on the type). The bottom line is that they have to be constants rather than variables.

    For example, glibc has:

    # define INT8_C(c)      c
    # define INT16_C(c)     c
    # define INT32_C(c)     c
    # if __WORDSIZE == 64
    #  define INT64_C(c)    c ## L
    # else
    #  define INT64_C(c)    c ## LL
    # endif
    

    which will allow your INT8_C macro to work fine but the text INT64_C(val) would be pre-processed into either valL or valLL, neither of which you would want.

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

Sidebar

Related Questions

Please see the code below: #include <windows.h> int main(int argc, char* argv[]) { HANDLE
Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i
Please see the code below: #include <iostream> #include <stdlib.h> #include <time.h> using namespace std;
I have a very simple c code: #include<stdio.h> int main() { enum boolean{true,false}; boolean
Please see the C++ code fragment below: #include ..... Class1 class1; Class2 class2; ...
Please see the following code: #include <iostream> #include <string> using namespace std; enum dataType
In code below (please see comment): #include stdafx.h #include <iostream> using std::cout; struct Base
folks please see following code : #include <gio/gio.h> #include <sys/socket.h> //socket(); #include <netinet/in.h> //sockaddr_in
folks, if you dont mind please see following code : #include <glib.h> #include <gio/gio.h>
please consider following code #include <iostream> using namespace std; class Digit { private: int

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.