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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:24:23+00:00 2026-06-14T10:24:23+00:00

I’m using VC++ to write a 128-bit integer class in C (wrapped the header

  • 0

I’m using VC++ to write a 128-bit integer “class” in C (wrapped the header in extern "C" block), however, during routine builds to check for errors, I encountered many after adding this function:

/* Negate (2s compliment NOT) a 128-bit integer */
INT128_INLINE void int128_neg(int128_t *ret, int128_t arg)
{
    /* 2s compliment negation is equivalent to ((~value) + 1) */

    int128_t one;
    int128_from_i8(&one, 1);

    int128_t inv;
    int128_inv(&inv, arg);

    int128_add(ret, one, inv);
}

Essentially, if it’s not clear enough, it finds the negative (-x) of a given int128_t. Here is the int128_t structure:

/* Work at the byte level to work around endianess crap */
/* (speaking of which, this is big endian, at least is should be) */
#pragma pack(1)
struct _int128_t
{
    /* SIGN BIT: 0xxxxxxx = positive; 1xxxxxxx = negative */
    uint8_t byte01; /* MSB */
    uint8_t byte02;
    uint8_t byte03;
    uint8_t byte04;
    uint8_t byte05;
    uint8_t byte06;
    uint8_t byte07;
    uint8_t byte08;
    uint8_t byte09;
    uint8_t byte10;
    uint8_t byte11;
    uint8_t byte12;
    uint8_t byte13;
    uint8_t byte14;
    uint8_t byte15;
    uint8_t byte16; /* LSB */
};

/* A 128-bit integer structure and functions written in pure C99 code :) */
typedef struct _int128_t int128_t;

and the function prototypes:

/* Invert (~) a 128-bit integer */
INT128_INLINE void int128_inv(int128_t *ret, int128_t arg) { ... }

/* Add two 128-bit integers together */
INT128_INLINE void int128_add(int128_t *ret, int128_t lhs, int128_t rhs) { ... }

and INT128_INLINE (obviously the one that sets it to __inline is used):

/* MC++ requires `__inline`*/
#ifdef _MSC_VER
#  define INT128_INLINE __inline
#else
   /* use standard inline */
#  define INT128_INLINE inline
#endif

Now, the errors I am receiving with the function are:

Error   24  error C2275: 'int128_t' : illegal use of this type as an expression d:\libplist\libplist\include\int128.h   313 1   libplist
Error   25  error C2146: syntax error : missing ';' before identifier 'inv' d:\libplist\libplist\include\int128.h   313 1   libplist
Error   26  error C2065: 'inv' : undeclared identifier  d:\libplist\libplist\include\int128.h   313 1   libplist
Error   28  error C2065: 'inv' : undeclared identifier  d:\libplist\libplist\include\int128.h   314 1   libplist
Error   29  error C2065: 'inv' : undeclared identifier  d:\libplist\libplist\include\int128.h   316 1   libplist
Error   30  error C2440: 'function' : cannot convert from 'int' to 'int128_t'   d:\libplist\libplist\include\int128.h   316 1   libplist
Error   32  error C2371: 'int128_inv' : redefinition; different basic types d:\libplist\libplist\include\int128.h   324 1   libplist

and before you ask, line 313 is the int128_t inv;. And also, libplist is an Apple PList library I am working on to work that uses libxml2 with the iTunes database (C:\Users\{YOU}\My Music\iTunes\iTunes Library.xml)

I tried rewriting the function to be sure it wasn’t some weird Unicode crap (like people do to troll with the R2L char), but it didn’t help. I tried doing int128_t inv = *ret;, but that just gives:

Error   27  error C2440: '=' : cannot convert from 'int128_t' to 'int'  d:\libplist\libplist\include\int128.h   313 1   libplist
  • 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-14T10:24:24+00:00Added an answer on June 14, 2026 at 10:24 am
    int128_t one;
    int128_from_i8(&one, 1);
    
    int128_t inv;
    int128_inv(&inv, arg);
    

    This is not valid C89 code because C89 requires that all variables are declared at the top of a function, and Visual C only supports C89. Declarations must appear before statements in a function. So, if you’re truly using the C compiler (and not the C++ compiler), this would cause errors. What you should be doing instead is:

    int128_t one;
    int128_t inv;
    
    int128_from_i8(&one, 1);
    int128_inv(&inv, arg);
    

    Also, this comment is incorrect:

    /* A 128-bit integer structure and functions written in pure C99 code :) */
    

    If you’re using Visual C, it’s C89, not C99, for the aforementioned reason. Microsoft’s said that they will never support any C standard later than C89 because they don’t feel it’s worth the effort and that everyone should be using C++ or C# instead. I don’t like it, but I can’t do anything about it; so, whatever.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.