How to fix strange behavior of anonymously created structure, when called in function?Strange behavior when overriding private methodsIs there a general-purpose printf-ish routine defined in any C standardarray of type voidDereferencing pointer to array of voidVoid pointers in C used in stacksFunction not working unless called in same filehow to move packet from NF_INET_PRE_ROUTING to NF_INET_POST_ROUTING?I2C-dev: Change write and read parametersHow do the printf function in C get the size of every parameter in the variable parameters list?How to “extract” a long double using va_arg?

Is it a problem that pull requests are approved without any comments

The ring of global sections of a regular scheme

Is it OK to bring delicacies from hometown as tokens of gratitude for an out-of-town interview?

Avoiding cliches when writing gods

When writing an error prompt, should we end the sentence with a exclamation mark or a dot?

Comma Code - Ch. 4 Automate the Boring Stuff

Past participle agreement with the subject in the case of pronominal verbs

Chopin: marche funèbre bar 15 impossible place

Opposite of "Squeaky wheel gets the grease"

Can Green-Flame Blade be cast twice with the Hunter ranger's Horde Breaker ability?

Accidentally renamed tar.gz file to a non tar.gz file, will my file be messed up

Incremental Ranges!

What are the words for people who cause trouble believing they know better?

Humans meet a distant alien species. How do they standardize? - Units of Measure

Movie where a boy is transported into the future by an alien spaceship

How to connect an offset point symbol to its original position in QGIS?

The term for the person/group a political party aligns themselves with to appear concerned about the general public

Do adult Russians normally hand-write Cyrillic as cursive or as block letters?

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

I wrote a scene that the majority of my readers loved. How do I get back to that place while writing my new book?

How can I determine the spell save DC of a monster/NPC?

How much water is needed to create a Katana capable of cutting flesh, bones and wood?

How to decline physical affection from a child whose parents are pressuring them?

Short story written from alien perspective with this line: "It's too bright to look at, so they don't"



How to fix strange behavior of anonymously created structure, when called in function?


Strange behavior when overriding private methodsIs there a general-purpose printf-ish routine defined in any C standardarray of type voidDereferencing pointer to array of voidVoid pointers in C used in stacksFunction not working unless called in same filehow to move packet from NF_INET_PRE_ROUTING to NF_INET_POST_ROUTING?I2C-dev: Change write and read parametersHow do the printf function in C get the size of every parameter in the variable parameters list?How to “extract” a long double using va_arg?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm trying to recreate an encapsulation principle in ANSI-C for educational purposes. What I essentially did was making some structure in .c file:



struct _private

unsigned char SizeInBytes;
unsigned char* matrix;
struct Stack* S;
unsigned char ByteX;
;


which represented variables I wanted to be unseen. Then in .h file inside the struct (class) I created an opaque pointer:



struct Maze

void* _private;
;


which I assign later in constructor function like this:



void* Maze_ctor(void* self, va_list *ap)

struct Maze* this = self;

this->DimX = va_arg(*ap, unsigned char);
this->DimY = va_arg(*ap, unsigned char);

this->_private = &(struct _private) // passing address of struct to void*

.SizeInBytes = this->DimX*this->DimY >> 1,
.S = new(Stack),
.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
;
//
private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);
S = new(Stack); // this in my new() and it works similar to C++ new

for (int i = 0; i < private.ByteX*this->DimY; i++)
*(private.matrix + i) = 0;



At this point everything works fine, but then I'm trying to call the Next() method:



int Next(void* self, ...)

struct Maze* this = self;

struct _private *r = this->_private;

short t;

toBinary(this); // after this point the struct private breaks



the prototype of toBinary() is:



void toBinary(const void* self)

// somehow char local is defined and equals to 204??
struct Maze *this = self;
struct _private *r = this->_private;

unsigned char local; // right after this point SizeInBytes equals to 204!
...



the question is: how to fix this problem. Using C++ is prohibited!
for the interested ones: here is new()



void* new(const void* _class,...)

const struct Class* class = _class; // we need to convert pointer from void* to class* safely
void *p = calloc(1, class->size); // allocation of memory for class .using size param

assert(p); // if Null -> throw an error
*(const struct Class**)p = class; // safe assignment of class pointer to (value) of p, to have memory and built in funcs
if (class->ctor) // if has constructor with some dynal in it, execute with varargs on its input

va_list ap;
va_start(ap, _class); //
p = class->ctor(p, &ap); // pass arguments as a list of pointers.
va_end(ap);

return p; //returns a pointer to class pointer (weird but worx)










share|improve this question



















  • 2





    If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

    – Sami Kuhmonen
    Mar 24 at 13:33











  • @PaulOgilvie the compiler is set to /TC, this ought to be C

    – Ilya Pakhmutov
    Mar 24 at 13:36











  • Do you want C or TC (whatever TC may be)?

    – Paul Ogilvie
    Mar 24 at 13:38











  • @IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

    – alinsoar
    Mar 24 at 13:39











  • @PaulOgilvie /TC is a MSVC compiler option for compiling C code

    – Ilya Pakhmutov
    Mar 24 at 13:39

















1















I'm trying to recreate an encapsulation principle in ANSI-C for educational purposes. What I essentially did was making some structure in .c file:



struct _private

unsigned char SizeInBytes;
unsigned char* matrix;
struct Stack* S;
unsigned char ByteX;
;


which represented variables I wanted to be unseen. Then in .h file inside the struct (class) I created an opaque pointer:



struct Maze

void* _private;
;


which I assign later in constructor function like this:



void* Maze_ctor(void* self, va_list *ap)

struct Maze* this = self;

this->DimX = va_arg(*ap, unsigned char);
this->DimY = va_arg(*ap, unsigned char);

this->_private = &(struct _private) // passing address of struct to void*

.SizeInBytes = this->DimX*this->DimY >> 1,
.S = new(Stack),
.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
;
//
private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);
S = new(Stack); // this in my new() and it works similar to C++ new

for (int i = 0; i < private.ByteX*this->DimY; i++)
*(private.matrix + i) = 0;



At this point everything works fine, but then I'm trying to call the Next() method:



int Next(void* self, ...)

struct Maze* this = self;

struct _private *r = this->_private;

short t;

toBinary(this); // after this point the struct private breaks



the prototype of toBinary() is:



void toBinary(const void* self)

// somehow char local is defined and equals to 204??
struct Maze *this = self;
struct _private *r = this->_private;

unsigned char local; // right after this point SizeInBytes equals to 204!
...



the question is: how to fix this problem. Using C++ is prohibited!
for the interested ones: here is new()



void* new(const void* _class,...)

const struct Class* class = _class; // we need to convert pointer from void* to class* safely
void *p = calloc(1, class->size); // allocation of memory for class .using size param

assert(p); // if Null -> throw an error
*(const struct Class**)p = class; // safe assignment of class pointer to (value) of p, to have memory and built in funcs
if (class->ctor) // if has constructor with some dynal in it, execute with varargs on its input

va_list ap;
va_start(ap, _class); //
p = class->ctor(p, &ap); // pass arguments as a list of pointers.
va_end(ap);

return p; //returns a pointer to class pointer (weird but worx)










share|improve this question



















  • 2





    If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

    – Sami Kuhmonen
    Mar 24 at 13:33











  • @PaulOgilvie the compiler is set to /TC, this ought to be C

    – Ilya Pakhmutov
    Mar 24 at 13:36











  • Do you want C or TC (whatever TC may be)?

    – Paul Ogilvie
    Mar 24 at 13:38











  • @IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

    – alinsoar
    Mar 24 at 13:39











  • @PaulOgilvie /TC is a MSVC compiler option for compiling C code

    – Ilya Pakhmutov
    Mar 24 at 13:39













1












1








1








I'm trying to recreate an encapsulation principle in ANSI-C for educational purposes. What I essentially did was making some structure in .c file:



struct _private

unsigned char SizeInBytes;
unsigned char* matrix;
struct Stack* S;
unsigned char ByteX;
;


which represented variables I wanted to be unseen. Then in .h file inside the struct (class) I created an opaque pointer:



struct Maze

void* _private;
;


which I assign later in constructor function like this:



void* Maze_ctor(void* self, va_list *ap)

struct Maze* this = self;

this->DimX = va_arg(*ap, unsigned char);
this->DimY = va_arg(*ap, unsigned char);

this->_private = &(struct _private) // passing address of struct to void*

.SizeInBytes = this->DimX*this->DimY >> 1,
.S = new(Stack),
.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
;
//
private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);
S = new(Stack); // this in my new() and it works similar to C++ new

for (int i = 0; i < private.ByteX*this->DimY; i++)
*(private.matrix + i) = 0;



At this point everything works fine, but then I'm trying to call the Next() method:



int Next(void* self, ...)

struct Maze* this = self;

struct _private *r = this->_private;

short t;

toBinary(this); // after this point the struct private breaks



the prototype of toBinary() is:



void toBinary(const void* self)

// somehow char local is defined and equals to 204??
struct Maze *this = self;
struct _private *r = this->_private;

unsigned char local; // right after this point SizeInBytes equals to 204!
...



the question is: how to fix this problem. Using C++ is prohibited!
for the interested ones: here is new()



void* new(const void* _class,...)

const struct Class* class = _class; // we need to convert pointer from void* to class* safely
void *p = calloc(1, class->size); // allocation of memory for class .using size param

assert(p); // if Null -> throw an error
*(const struct Class**)p = class; // safe assignment of class pointer to (value) of p, to have memory and built in funcs
if (class->ctor) // if has constructor with some dynal in it, execute with varargs on its input

va_list ap;
va_start(ap, _class); //
p = class->ctor(p, &ap); // pass arguments as a list of pointers.
va_end(ap);

return p; //returns a pointer to class pointer (weird but worx)










share|improve this question
















I'm trying to recreate an encapsulation principle in ANSI-C for educational purposes. What I essentially did was making some structure in .c file:



struct _private

unsigned char SizeInBytes;
unsigned char* matrix;
struct Stack* S;
unsigned char ByteX;
;


which represented variables I wanted to be unseen. Then in .h file inside the struct (class) I created an opaque pointer:



struct Maze

void* _private;
;


which I assign later in constructor function like this:



void* Maze_ctor(void* self, va_list *ap)

struct Maze* this = self;

this->DimX = va_arg(*ap, unsigned char);
this->DimY = va_arg(*ap, unsigned char);

this->_private = &(struct _private) // passing address of struct to void*

.SizeInBytes = this->DimX*this->DimY >> 1,
.S = new(Stack),
.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
;
//
private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);
S = new(Stack); // this in my new() and it works similar to C++ new

for (int i = 0; i < private.ByteX*this->DimY; i++)
*(private.matrix + i) = 0;



At this point everything works fine, but then I'm trying to call the Next() method:



int Next(void* self, ...)

struct Maze* this = self;

struct _private *r = this->_private;

short t;

toBinary(this); // after this point the struct private breaks



the prototype of toBinary() is:



void toBinary(const void* self)

// somehow char local is defined and equals to 204??
struct Maze *this = self;
struct _private *r = this->_private;

unsigned char local; // right after this point SizeInBytes equals to 204!
...



the question is: how to fix this problem. Using C++ is prohibited!
for the interested ones: here is new()



void* new(const void* _class,...)

const struct Class* class = _class; // we need to convert pointer from void* to class* safely
void *p = calloc(1, class->size); // allocation of memory for class .using size param

assert(p); // if Null -> throw an error
*(const struct Class**)p = class; // safe assignment of class pointer to (value) of p, to have memory and built in funcs
if (class->ctor) // if has constructor with some dynal in it, execute with varargs on its input

va_list ap;
va_start(ap, _class); //
p = class->ctor(p, &ap); // pass arguments as a list of pointers.
va_end(ap);

return p; //returns a pointer to class pointer (weird but worx)







c class private encapsulation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 13:58







Ilya Pakhmutov

















asked Mar 24 at 13:26









Ilya PakhmutovIlya Pakhmutov

569




569







  • 2





    If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

    – Sami Kuhmonen
    Mar 24 at 13:33











  • @PaulOgilvie the compiler is set to /TC, this ought to be C

    – Ilya Pakhmutov
    Mar 24 at 13:36











  • Do you want C or TC (whatever TC may be)?

    – Paul Ogilvie
    Mar 24 at 13:38











  • @IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

    – alinsoar
    Mar 24 at 13:39











  • @PaulOgilvie /TC is a MSVC compiler option for compiling C code

    – Ilya Pakhmutov
    Mar 24 at 13:39












  • 2





    If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

    – Sami Kuhmonen
    Mar 24 at 13:33











  • @PaulOgilvie the compiler is set to /TC, this ought to be C

    – Ilya Pakhmutov
    Mar 24 at 13:36











  • Do you want C or TC (whatever TC may be)?

    – Paul Ogilvie
    Mar 24 at 13:38











  • @IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

    – alinsoar
    Mar 24 at 13:39











  • @PaulOgilvie /TC is a MSVC compiler option for compiling C code

    – Ilya Pakhmutov
    Mar 24 at 13:39







2




2





If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

– Sami Kuhmonen
Mar 24 at 13:33





If I’m not entirely mistaken you’re creating a local struct and assigning it to the pointer. After the function finishes it’s gone and you have a dangling pointer. You need dynamic memory allocation.

– Sami Kuhmonen
Mar 24 at 13:33













@PaulOgilvie the compiler is set to /TC, this ought to be C

– Ilya Pakhmutov
Mar 24 at 13:36





@PaulOgilvie the compiler is set to /TC, this ought to be C

– Ilya Pakhmutov
Mar 24 at 13:36













Do you want C or TC (whatever TC may be)?

– Paul Ogilvie
Mar 24 at 13:38





Do you want C or TC (whatever TC may be)?

– Paul Ogilvie
Mar 24 at 13:38













@IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

– alinsoar
Mar 24 at 13:39





@IlyaPakhmutov If you want to implement the concepts of OOP in C there are lots of courses whose contents you can find online. Here please paste a code that we can execute to see ourselves what you mean.

– alinsoar
Mar 24 at 13:39













@PaulOgilvie /TC is a MSVC compiler option for compiling C code

– Ilya Pakhmutov
Mar 24 at 13:39





@PaulOgilvie /TC is a MSVC compiler option for compiling C code

– Ilya Pakhmutov
Mar 24 at 13:39












2 Answers
2






active

oldest

votes


















2














As pointed out in the comment, the problem is that you created a local object and assign it to a pointer this. Outside that function, the value of this is not valid.



You code,



void* Maze_ctor(void* self, va_list *ap)

//....
// this creates a temporary object and will be destroyed after Maz_ctor returns.

this->_private = &(struct _private) // passing address of struct to void*

.SizeInBytes = this->DimX*this->DimY >> 1,
.S = new(Stack),
.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
;
// ---






share|improve this answer






























    0














    Thanks to @Sami Kuhmonen for pointing out on dynamic allocation and @CS Pei for mistake analysis. The thing I did to fix this is:



    struct Maze

    char _private[32]; // allocate the memory size of struct(32)



    // assign values to void ptr
    private.SizeInBytes = this->DimX*this->DimY >> 1;
    private.S = new(Stack);
    private.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8;
    private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);


    this now works as intended, but a little slower






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324263%2fhow-to-fix-strange-behavior-of-anonymously-created-structure-when-called-in-fun%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      As pointed out in the comment, the problem is that you created a local object and assign it to a pointer this. Outside that function, the value of this is not valid.



      You code,



      void* Maze_ctor(void* self, va_list *ap)

      //....
      // this creates a temporary object and will be destroyed after Maz_ctor returns.

      this->_private = &(struct _private) // passing address of struct to void*

      .SizeInBytes = this->DimX*this->DimY >> 1,
      .S = new(Stack),
      .ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
      ;
      // ---






      share|improve this answer



























        2














        As pointed out in the comment, the problem is that you created a local object and assign it to a pointer this. Outside that function, the value of this is not valid.



        You code,



        void* Maze_ctor(void* self, va_list *ap)

        //....
        // this creates a temporary object and will be destroyed after Maz_ctor returns.

        this->_private = &(struct _private) // passing address of struct to void*

        .SizeInBytes = this->DimX*this->DimY >> 1,
        .S = new(Stack),
        .ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
        ;
        // ---






        share|improve this answer

























          2












          2








          2







          As pointed out in the comment, the problem is that you created a local object and assign it to a pointer this. Outside that function, the value of this is not valid.



          You code,



          void* Maze_ctor(void* self, va_list *ap)

          //....
          // this creates a temporary object and will be destroyed after Maz_ctor returns.

          this->_private = &(struct _private) // passing address of struct to void*

          .SizeInBytes = this->DimX*this->DimY >> 1,
          .S = new(Stack),
          .ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
          ;
          // ---






          share|improve this answer













          As pointed out in the comment, the problem is that you created a local object and assign it to a pointer this. Outside that function, the value of this is not valid.



          You code,



          void* Maze_ctor(void* self, va_list *ap)

          //....
          // this creates a temporary object and will be destroyed after Maz_ctor returns.

          this->_private = &(struct _private) // passing address of struct to void*

          .SizeInBytes = this->DimX*this->DimY >> 1,
          .S = new(Stack),
          .ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8
          ;
          // ---







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 at 13:41









          CS PeiCS Pei

          8,5822040




          8,5822040























              0














              Thanks to @Sami Kuhmonen for pointing out on dynamic allocation and @CS Pei for mistake analysis. The thing I did to fix this is:



              struct Maze

              char _private[32]; // allocate the memory size of struct(32)



              // assign values to void ptr
              private.SizeInBytes = this->DimX*this->DimY >> 1;
              private.S = new(Stack);
              private.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8;
              private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);


              this now works as intended, but a little slower






              share|improve this answer





























                0














                Thanks to @Sami Kuhmonen for pointing out on dynamic allocation and @CS Pei for mistake analysis. The thing I did to fix this is:



                struct Maze

                char _private[32]; // allocate the memory size of struct(32)



                // assign values to void ptr
                private.SizeInBytes = this->DimX*this->DimY >> 1;
                private.S = new(Stack);
                private.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8;
                private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);


                this now works as intended, but a little slower






                share|improve this answer



























                  0












                  0








                  0







                  Thanks to @Sami Kuhmonen for pointing out on dynamic allocation and @CS Pei for mistake analysis. The thing I did to fix this is:



                  struct Maze

                  char _private[32]; // allocate the memory size of struct(32)



                  // assign values to void ptr
                  private.SizeInBytes = this->DimX*this->DimY >> 1;
                  private.S = new(Stack);
                  private.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8;
                  private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);


                  this now works as intended, but a little slower






                  share|improve this answer















                  Thanks to @Sami Kuhmonen for pointing out on dynamic allocation and @CS Pei for mistake analysis. The thing I did to fix this is:



                  struct Maze

                  char _private[32]; // allocate the memory size of struct(32)



                  // assign values to void ptr
                  private.SizeInBytes = this->DimX*this->DimY >> 1;
                  private.S = new(Stack);
                  private.ByteX = this->DimX % 8 > 0 ? this->DimX / 8 + 1 : this->DimX / 8;
                  private.matrix = (unsigned char*)malloc(private.ByteX*this->DimY);


                  this now works as intended, but a little slower







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 24 at 15:45

























                  answered Mar 24 at 14:37









                  Ilya PakhmutovIlya Pakhmutov

                  569




                  569



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324263%2fhow-to-fix-strange-behavior-of-anonymously-created-structure-when-called-in-fun%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript