| | |
What is the use of #define _REENTRANT in my code?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
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
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
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.
バルサミコ酢やっぱいらへんで
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
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
This is a long shot, but can you just try this and tell me what happens?
c Syntax (Toggle Plain Text)
#ifndef _REENTRANT #define _REENTRANT #endif #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <iostream.h> #include <cmqc.h> #include <string.h> #include <wait.h> #include <sys/wait.h>
バルサミコ酢やっぱいらへんで
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
This is a long shot, but can you just try this and tell me what happens?
c Syntax (Toggle Plain Text)
#ifndef _REENTRANT #define _REENTRANT #endif #include <stdlib.h> #include <unistd.h> #include <ctype.h> #include <iostream.h> #include <cmqc.h> #include <string.h> #include <wait.h> #include <sys/wait.h>
Thanks
Ravi
![]() |
Similar Threads
- Assembly, machine code and compilers (Assembly)
- #define or const? (C)
- reading a file into code (Java)
- Some help understanding #define with C (C)
Other Threads in the C++ Forum
- Previous Thread: Need help with one line of code :(
- Next Thread: Error: Cannot convert double ()() to double
Views: 5993 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






