NO

Author Topic: Failing code  (Read 10677 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Failing code
« Reply #15 on: February 19, 2015, 06:42:02 PM »
I created a compiler patch for the broken _msize.
You can find it here.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline jcfuller

  • Member
  • *
  • Posts: 36
Re: Failing code
« Reply #16 on: February 20, 2015, 12:02:35 PM »
frankie,
  Did you try it with the original code example I posted?
It fails here.

James

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Failing code
« Reply #17 on: February 20, 2015, 02:05:37 PM »
frankie,
  Did you try it with the original code example I posted?
It fails here.
Hi James
I used your code to test in 32 and 64 bits. Please find attached the demo project. Maybe you included the header in the wrong place. Remember it must be always the last system header that you include.
Please let me know.

EDIT: Ok I got it! My wrong, in the usage description I was not clear enaugh. The former version must have been included after the last system header, not the last header... :( The situation got even worst because you include a C file (that while formally correct should be avoided in C).
So to keep it simple I made a decision to change the code. The new version must be the very first header in your code, can even preceed the system definitions.
I have already updated the patch, and the code below.
« Last Edit: February 20, 2015, 06:30:35 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline jcfuller

  • Member
  • *
  • Posts: 36
Re: Failing code
« Reply #18 on: February 20, 2015, 03:58:44 PM »
frankie,
  Thanks again for your support but....
I do not do things the conventional way. I know I should have multiple modules but that's a bit of a PIA as I compile with batch files. Just an -m32 or -m64 and I have 32/64.
What I have done and might be an alternate approach for you too is to create a 32/64 static library from pellescmem.c and put them in the appropriate win/win64 lib folders.
Now with #include <pellescmem.h> at the top and a #pragma comment(lib,"pellescmem.lib") it seems to work fine.
Do you see any problems with this approach?
James

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Failing code
« Reply #19 on: February 20, 2015, 05:02:08 PM »
What I have done and might be an alternate approach for you too is to create a 32/64 static library from pellescmem.c and put them in the appropriate win/win64 lib folders.
Now with #include <pellescmem.h> at the top and a #pragma comment(lib,"pellescmem.lib") it seems to work fine.
Do you see any problems with this approach?
James
James,
it is an absolutely legitimate solution. I've not created a library because is such a small code ... you know.  :)
Your approach works much better when compiling sources with different compilers, enclose the header between an ifdef:
Code: [Select]
#ifdef __POCC__
#include "pellescmem.h"
#endif
and ... voilĂ !  ;D
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide