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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:53:49+00:00 2026-05-25T19:53:49+00:00

I have a very odd issue trying to run this quite simple C program

  • 0

I have a very odd issue trying to run this quite simple C program which is using zmq and msgpack.

There is no problem with server.c, however in clinet.c:39 there
is this msgpack_pack_int (&mpkg, i); and the value of i seems
to be picked up as 0 and doesn’t change on each iteration. I
have tried a bunch of different things (e.g. making a pointer to
i and using that, also tried to split it into a function etc)
and nothing seems to help. I can see that msgpack_pack_int() is
a macro, but why it would introduce such a behaviour and what can
I do to overcome it? Is there a flag that could change the behaviour
of this kind of macro (as I see it expands to an inline function)…
I have tried -Werror -Wall, with gcc and clang, and nothing
comes up in warning either ;(*

I tried debugging it and i increments as expected.

I even tried this, and it would do the same thing anyway:

void pack (msgpack_packer *p, msgpack_sbuffer *b) {

   static volatile int i = 0;

   printf("\ni=%d\n", i);
   msgpack_packer_init (p, b, msgpack_sbuffer_write);
   msgpack_pack_array (p, 2);
   msgpack_pack_int (p, i++);
   msgpack_pack_str (p, "/i/am/a/clinet/");

}

I have even tried something which was supposed to be different, but no luck here either –

int count (void) {
    static int i = 0;
    i += 1; return i;
}

can anyone see why would this happen?

Update 1: Also I have recompiled msgpack library itself without optimization flags,
and that didn’t change the behaviour either.

Update 2: Installed msgpack from the git repo and I get still have the same issue.

  • 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-25T19:53:50+00:00Added an answer on May 25, 2026 at 7:53 pm

    It turns out that on each iteration I was doing this:

     msgpack_packer_init (&mpkg, &sbuf, msgpack_sbuffer_write);
    

    that needs to be done only once, and this should be there instead:

     msgpack_sbuffer_init (&sbuf);
    

    or:

     msgpack_sbuffer_clear (&sbuf);
    

    It was rather logical to put msg_pack* functions together and indeed
    that was taken from the simple example and
    the problem is really with the documentation, one extra comment would help!

    Update: working version & version without memcpy.

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

Sidebar

Related Questions

I have a very simple WPF application in which I am using data binding
I'm having this very odd issue while trying to serialize a class for logging
I have having a very odd issue when utilizing this UIAlertView. When viewing a
Let give you the details of this rather odd issue. We have a very
I have very simple select like this: SELECT * FROM table WHERE column1 IN
I have a very simple problem which requires a very quick and simple solution
I have a very odd issue. When I execute a specific database stored procedure
I have a very odd issue, where I've created a custom MSBuild task that
I have a very odd performance issue with an SSIS package in Sql Server
I have very little experience building software for Windows, and zero experience using the

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.