944,047 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 9160
  • C++ RSS
Oct 26th, 2006
0

What is the use of #define _REENTRANT in my code?

Expand Post »
Hi,
I am having problems with my C++ Programs on Sun Solaris server since I have upgraded my C++ compiler from Sun Forte Developer 7 compiler to Sun Studio 9 C++ complier 5.6.

I have my own string class which I had issues but now compiles ok after puting option -library=iostream in my makefile.

My string library make file has " /opt/SUNWspro/bin/CC -g -xs -xar -library=iostream -YP " options wwhile compiling.

After creating my libraries, I compiled my main C++ program, which compiles OK but when I execute I get following error.

"getfile: syntax error at line 2 : `newline or ;' unexpected"

getfile.c is my c++ program which has following code at the start.
-------------------------------------------------
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <iostream.h>
#include <cmqc.h>
#define _REENTRANT
#include <string.h>
#include <wait.h>
#include <sys/wait.h>
-----------------------------------------------------
I can't understand where in line 2 I am having errors.

If I remove _REENTRANT then I get the following error
"The function "strtok_r" must have a prototype." which I have used in my code in the same getfile.c program.

Any suggestions comments will be very much appreciated.

Thanks
Ravi
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rbhave is offline Offline
3 posts
since Oct 2006
Oct 26th, 2006
0

Re: What is the use of #define _REENTRANT in my code?

If it is your code, and you wrote that line, how come you are asking us what the meaning of that particular line is? Anyway, judging from the meaning of the word Re-entrant, that would mean that this program is designed to be run in multiple threads, and very well maybe a compiler specific flag. You better refer the compiler documentation or the program documentation if it was not written by you. Anyother things would be difficult to say unless we see the relevant source code.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Oct 27th, 2006
0

Re: What is the use of #define _REENTRANT in my code?

Click to Expand / Collapse  Quote originally posted by WolfPack ...
If it is your code, and you wrote that line, how come you are asking us what the meaning of that particular line is? Anyway, judging from the meaning of the word Re-entrant, that would mean that this program is designed to be run in multiple threads, and very well maybe a compiler specific flag. You better refer the compiler documentation or the program documentation if it was not written by you. Anyother things would be difficult to say unless we see the relevant source code.

Thanks for the prompt reply.
I have written the code few years back and copied most of it from HP Server earlier. I know _REENTRANT does in a sence that it allows the program to be multi threaded. But I could not understand when I removed it why I am geting the strtok error.
When I live it the REENTRANT code the program compiles without any errors/warnings but when I execute it it gives error at line 2
"getfile: syntax error at line 2 : `newline or ;' unexpected"
which I cann;t understand.
I have enclosed the getfile.c code which has lot of MQ related code and my own local include files, but if you look at the code there is nothing wrong at line 2.
Any more suggestions.
Thanks
Ravi
Attached Files
File Type: c getfile.c (23.8 KB, 29 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rbhave is offline Offline
3 posts
since Oct 2006
Oct 27th, 2006
0

Re: What is the use of #define _REENTRANT in my code?

This is a long shot, but can you just try this and tell me what happens?
  1. #ifndef _REENTRANT
  2. #define _REENTRANT
  3. #endif
  4.  
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <ctype.h>
  8. #include <iostream.h>
  9. #include <cmqc.h>
  10. #include <string.h>
  11. #include <wait.h>
  12. #include <sys/wait.h>
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Oct 27th, 2006
0

Re: What is the use of #define _REENTRANT in my code?

Click to Expand / Collapse  Quote originally posted by WolfPack ...
This is a long shot, but can you just try this and tell me what happens?
  1. #ifndef _REENTRANT
  2. #define _REENTRANT
  3. #endif
  4.  
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <ctype.h>
  8. #include <iostream.h>
  9. #include <cmqc.h>
  10. #include <string.h>
  11. #include <wait.h>
  12. #include <sys/wait.h>
Tried your suggestion in my getfile.c program and still the same error.
Thanks
Ravi
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rbhave is offline Offline
3 posts
since Oct 2006
Oct 27th, 2006
0

Re: What is the use of #define _REENTRANT in my code?

Sorry no idea. Never developed anything in the Solaris environment. So guess someone else will have to take over this thread.
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Jun 15th, 2010
-1
Re: What is the use of #define _REENTRANT in my code?
Take off the line #define _REENTRANT from your file
Instead use the following flag during compilation.
CC -c -D_SOLARIS_ -D_REENTRANT
Let me know if it fixed your problem.
Reputation Points: 9
Solved Threads: 0
Newbie Poster
psoma74 is offline Offline
1 posts
since Jun 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Character Array Initialization
Next Thread in C++ Forum Timeline: expression: vector subscript out of range





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC