C : #pragma pointer_size ignored???

Post Reply

Topic author
joukj
Master
Posts: 175
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

C : #pragma pointer_size ignored???

Post by joukj » Mon Dec 04, 2023 4:51 am

Hi All

I get the following:

rumba-jj) cc/vers
VSI C x86-64 X7.4-843 (GEM 50XB9) on OpenVMS x86_64 V9.2-1
rumba-jj) ty test.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
#pragma pointer_size 64
int* i = (int*) malloc( 80 );

#pragma pointer_size 32
int* i2 = (int*) malloc( 80 );
printf( "%u %u" , i , i2 );
return 0;
}
4-DEC-2023 10:47:22
rumba-jj) cc/point=32 test.c
rumba-jj) link test
rumba-jj) run test
27984 28096
rumba-jj) cc/point=64 test.c
rumba-jj) link test
rumba-jj) run test
2147508256 2147508368


Looks like the #pragma pointer_size is ignored. I get the same on IA64. What do I do wrong?

Jouk


pustovetov
VSI Expert
Contributor
Posts: 18
Joined: Thu Sep 14, 2023 1:26 am
Reputation: 0
Status: Offline

Re: C : #pragma pointer_size ignored???

Post by pustovetov » Mon Dec 04, 2023 5:16 am

joukj wrote:
Mon Dec 04, 2023 4:51 am
Hi All

I get the following:

rumba-jj) cc/vers
VSI C x86-64 X7.4-843 (GEM 50XB9) on OpenVMS x86_64 V9.2-1
rumba-jj) ty test.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
#pragma pointer_size 64
int* i = (int*) malloc( 80 );

#pragma pointer_size 32
int* i2 = (int*) malloc( 80 );
printf( "%u %u" , i , i2 );
return 0;
}

Looks like the #pragma pointer_size is ignored. I get the same on IA64. What do I do wrong?
Try this:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
int main()
{
#pragma pointer_size 64
   int* i = _malloc64( 80 );
   
#pragma pointer_size 32
   int* i2 = _malloc32( 80 );
   printf( "%u %u" , i , i2 );
   return 0;
}
This pragma changes the type of pointers but does not cause the correct function to be substituted.


Topic author
joukj
Master
Posts: 175
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: C : #pragma pointer_size ignored???

Post by joukj » Mon Dec 04, 2023 5:47 am

Thanks, that helps

Post Reply