PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

win32 compile problem: illegal symbol __pragma

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
dima2011



Joined: 11 May 2011
Posts: 8

PostPosted: Mon Jul 15, 2013 5:00 am    Post subject: win32 compile problem: illegal symbol __pragma Reply with quote

I suspect something is wrong with my installation of PGI 13.6 on Windows. Can you help to identify what is wrong?

> type x.c
#include <malloc.h>
int main(){return 0;}

> pgcc --version
PGI Workstation 13.6

pgcc 13.6-0 32-bit target on x86-64 Windows -tp sandybridge
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2013, STMicroelectronics, Inc. All Rights Reserved.

> pgcc -c x.c
PGI Workstation 13.6
PGC-S-0040-Illegal use of symbol, warning (C:/Program Files/PGI/Microsoft Open Tools 11/include\malloc.h: 237)
PGC-W-0156-Type not specified, 'int' assumed (C:/Program Files/PGI/Microsoft Open Tools 11/include\malloc.h: 237)
...
PGC/x86 Windows 13.6-0: compilation completed with severe errors

malloc.h uses __pragma(warning(push)) on the mentioned line. Pgcc expects _Pragma("string"), I think.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6213
Location: The Portland Group Inc.

PostPosted: Mon Jul 15, 2013 9:43 am    Post subject: Reply with quote

Hi dima2011,

Sorry but you can't include "malloc.h" on Windows. MS recently added a bunch of non-standard MS specific code to the header file and we weren't able to work around them. If you're just using "malloc", then there's no need to include "malloc.h". It will be declared implicitly.

- Mat
Back to top
View user's profile
dima2011



Joined: 11 May 2011
Posts: 8

PostPosted: Mon Jul 15, 2013 7:58 pm    Post subject: Reply with quote

Hi Mat,

Thank you for clarification. However, one must declare malloc() anyway, because return type 'int' of implicit declaration is different from actual 'void*' returned by malloc(). On a 64-bit system if you are 'just using malloc' you will get what you deserve - likely and hopefully a segmentation fault. To make the application portable you have to declare malloc() explicitly. With pgcc on windows there are these options, at least:

1. Declare the missing function or functions like this
#if defined(__PGIC__)
extern void *malloc(size_t);
#else
#include <malloc.h>
#endif

2. Or make pgcc understand Microsoft's __pragma keyword:
#if defined(__PGIC__)
#define __pragma(arg) _PRAGMA_STRINGIFY(arg)
#define _PRAGMA_STRINGIFY(a) _PRAGMA(#a)
#define _PRAGMA(a) _Pragma(a)
#endif
#include <malloc.h>

What is your recommendation?
Does PGI have plans to support Microsoft's extensions on Windows?

Thanks
Dima
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group