CC compiler problem with string.h

Hi,
I use Sun Studio Express (3-Dec-2006 Build) on SUSE Linux 10.1.
When I was trying to compile the following code, I got an error message regarding <string.h>. The same codes works fine with g++ compiler.
Please give me some comments on that.
Thanks.
Tae-Suk Bae
#include <stdio.h>
#include <string.h>
int main(int argc, char**argv) {
char str[80];
strcpy(str,"Test");
printf("%s\n",str);
return 0;
CC -c -g -o build/Debug/Sun-Linux-x86/welcome.o welcome.cc
(/home/baezae/ngsode/Welcome1)welcome.cc:
"/usr/include/string.h", line 272: Error: End of file encountered in macro arguments for "__nonnull".
"/usr/include/string.h", line 272: Error: ")" expected instead of "(".
"/usr/include/string.h", line 272: Error: Unexpected ")" -- Check for matching parenthesis.
"/usr/include/string.h", line 272: Error: Operand expected instead of ";".
"/usr/include/string.h", line 426: Error: "strerror_r(int, char*, unsigned)" is expected to return a value.
"welcome.cc", line 30: Error: "}" expected instead of "end of file".
6 Error(s) detected.
----------------------------------------------------------

I have that feeling that this has been solved in later version, February build. It is available for download here: http://developers.sun.com/sunstudio/downloads/express.jsp
Maybe compiler experts will be able to provide more accurate answer, though.

Similar Messages

  • Problem with String variable

    I am new to Java Programming.
    I have a line of code that works and does what is supposed to.
    faceData.getProfile("Lisa").removeFriend("Curtis");
    If I assign the strings to variables such as-
    String name = "Lisa";
    String fName = "Curtis";
    and then plug those into the same line of code, it does not work
    faceData.getProfile(name).removeFriend(fName);
    What could be causing the problem?
    I even added some lines to print out what is stored in the variables to verify that they are what they should be, but for some reason the variables do not work while putting the strings in quotes does. Any ideas?

    I guarantee that something about your assertions are incorrect. Those variables are either not equal to the values you claim, or something else is going on. But it's not a problem with string variables versus string constants.
    Edit: My best guess in lack of a real example from you, is that the strings in question have non-printable characters in them, such as trailing spaces or line feeds.

  • Little problem with Strings.

              I have an little problem with Strings, i make one comparision like this.
              String nombre="Javier";
              if( nombre.equalsIgnoreCase(output.getStringValue("CN_NOMBRESf",null)) )
              Wich output.getStringValue("CN_NOMBRESf",null) is "Javier" too, because I display
              this before and are equals.
              What I do wrong?.
              

    You are actually making your users key in things like
    "\026"? Not very user-friendly, I would say. But
    assuming that is the best way for you to get your
    input, or if it's just you doing the input, the way to
    change that 4-character string into the single
    character that Java represents by '\026', you would
    use a bit of code like this:char encoded =
    (char)Integer.parseInt(substring(inputString, 1),
    16);
    DrClap has the right idea, except '\026' is octal, not hex. So change the radix from 16 to 8. Unicode is usually represented like '\u002A'. So it looks like you want:String s = "\\077";
    System.out.println((char)Integer.parseInt(s.substring(1), 8));Now all you have to do is parse through the String and replace them, which I think shouldn't be too hard for you now :)

  • Compilation problem with templates while using option -m64

    Hi,
    I have compilation problem with template while using option -m64.
    No problem while using option -m32.
    @ uname -a
    SunOS snt5010 5.10 Generic_127111-11 sun4v sparc SUNW,SPARC-Enterprise-T5220
    $ CC -V
    CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
    Here is some C++ program
    ############# foo5.cpp #############
    template <typename T, T N, unsigned long S = sizeof(T) * 8>
    struct static_number_of_ones
    static const T m_value = static_number_of_ones<T, N, S - 1>::m_value >> 1;
    static const unsigned long m_count = static_number_of_ones<T, N, S - 1>::m_count + (static_number_of_ones<T, N, S - 1>::m_value & 0x1);
    template <typename T, T N>
    struct static_number_of_ones<T, N, 0>
    static const T m_value = N;
    static const unsigned long m_count = 0;
    template <typename T, T N>
    struct static_is_power_of_2
    static const bool m_result = (static_number_of_ones<T,N>::m_count == 1);
    template <unsigned long N>
    struct static_number_is_power_of_2
    static const bool m_result = (static_number_of_ones<unsigned long, N>::m_count == 1);
    int main(int argc)
    int ret = 0;
    if (argc > 1)
    ret += static_is_power_of_2<unsigned short, 16>::m_result;
    ret += static_is_power_of_2<unsigned int, 16>::m_result;
    ret += static_is_power_of_2<unsigned long, 16>::m_result;
    ret += static_number_is_power_of_2<16>::m_result;
    else
    ret += static_is_power_of_2<unsigned short, 17>::m_result;
    ret += static_is_power_of_2<unsigned int, 17>::m_result;
    ret += static_is_power_of_2<unsigned long, 17>::m_result;
    ret += static_number_is_power_of_2<17>::m_result;
    return ret;
    Compiation:
    @ CC -m32 foo5.cpp
    // No problem
    @ CC -m64 foo5.cpp
    "foo5.cpp", line 20: Error: An integer constant expression is required here.
    "foo5.cpp", line 36: Where: While specializing "static_is_power_of_2<unsigned long, 16>".
    "foo5.cpp", line 36: Where: Specialized in non-template code.
    "foo5.cpp", line 26: Error: An integer constant expression is required here.
    "foo5.cpp", line 37: Where: While specializing "static_number_is_power_of_2<16>".
    "foo5.cpp", line 37: Where: Specialized in non-template code.
    "foo5.cpp", line 20: Error: An integer constant expression is required here.
    "foo5.cpp", line 43: Where: While specializing "static_is_power_of_2<unsigned long, 17>".
    "foo5.cpp", line 43: Where: Specialized in non-template code.
    "foo5.cpp", line 26: Error: An integer constant expression is required here.
    "foo5.cpp", line 44: Where: While specializing "static_number_is_power_of_2<17>".
    "foo5.cpp", line 44: Where: Specialized in non-template code.
    4 Error(s) detected.
    Predefined macro:
    @ CC -m32 -xdumpmacros=defs foo5.cpp | & tee log32
    @ CC -m64 -xdumpmacros=defs foo5.cpp | & tee log64
    @ diff log32 log64
    7c7
    < #define __TIME__ "09:24:58"
    #define __TIME__ "09:25:38"20c20
    < #define __sparcv8plus 1
    #define __sparcv9 1[snipped]
    =========================
    What is wrong?
    Thanks,
    Alex Vinokur

    Bug 6749491 has been filed for this problem. It will be visible at [http://bugs.sun.com] in a day or two.
    If you have a service contract with Sun, you can ask to have this bug's priority raised, and get a pre-release version of a compiler patch that fixes the problem.
    Otherwise, you can check for new patches from time to time at
    [http://developers.sun.com/sunstudio/downloads/patches/]
    and see whether this bug is listed as fixed.

  • Problem with String to Int conversion

    Dear Friends,
    Problem with String to Int conversion
    I am having a column where most of the values are numeric. Only 4 values are non numeric.
    I have replaces those non numeric values to numeric in order to maintain the data type.
    CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END
    This comes the result as down
    Grade
    _0_
    _1_
    _10_
    _11_
    _12_
    _13_
    _14_
    _15_
    _16_
    _17_
    _18_
    _19_
    _2_
    _20_
    _21_
    _22_
    _23_
    _24_
    _3_
    _4_
    _5_
    _6_
    _7_
    _8_
    _9_
    Refresh
    Now I want to convert this value to numeric and do some calculation
    So I changed the formula as below
    cast (CASE Grade.Grade  WHEN 'E4' THEN '24'  WHEN 'E3' THEN '23'  WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade  END as INT)
    Now I get the following error
    View Display Error
    _     Odbc driver returned an error (SQLExecDirectW)._
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    _State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1722, message: ORA-01722: invalid number at OCI call OCIStmtFetch. [nQSError: 17012] Bulk fetch failed. (HY000)_
    SQL Issued: SELECT cast ( CASE Grade.Grade WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' ELSE Grade.Grade END as Int) saw0 FROM "Human Capital - Manpower Costing" WHERE LENGTH(CASE Grade.Grade WHEN 'E1' THEN '20' WHEN 'E2' THEN '21' WHEN 'E3' THEN '22' WHEN 'E4' THEN '23' ELSE Grade.Grade END) > 0 ORDER BY saw_0_
    Refresh
    Could anybody help me
    Regards
    Mustafa
    Edited by: Musnet on Jun 29, 2010 5:42 AM
    Edited by: Musnet on Jun 29, 2010 6:48 AM

    Dear Kart,
    This give me another hint, Yes you are right. There was one row which returns neither blank nor any value.
    I have done the code like following and it works fine
    Thanks again for your support
    Regards
    Code: cast (CASE (CASE WHEN Length(Grade.Grade)=0 THEN '--' ELSE Grade.Grade END) WHEN 'E4' THEN '24' WHEN 'E3' THEN '23' WHEN 'E2' THEN '22' WHEN 'E1' THEN '21' when '--' then '-1' ELSE Grade.Grade END as Int)

  • [svn:fx-trunk] 11707: Fix incremental compilation problem with styles.

    Revision: 11707
    Author:   [email protected]
    Date:     2009-11-12 10:52:49 -0800 (Thu, 12 Nov 2009)
    Log Message:
    Fix incremental compilation problem with styles.
    QE notes: None.
    Doc notes: None.
    Bugs: SDK-24173
    Reviewer: Paul
    Tests run: checkintests
    Is noteworthy for integration: No.
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24173
    Modified Paths:
        flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/css/StylesContainer.java

    You have used elements like header, footer, footer1 and nav without using the correct DOCTYPE declaration. Replace the first line of your code with
    <!doctype html>
    Also have a look here for other problems http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fhome.surewest.net%2Fstorytales%2F test%2Fforposting.html
    After the above has been fixed, please come back here to fix the remaining problem(s)
    Gramps

  • Problem with String in a Vector

    I'm making a small hangman game. And I got a problem with putting words in a Vector... This is the code... Can someone tell me what I'm doing wrong?
    // First I define it.
    Vector Words;
    //  Then add the words
    Vector Words = new Vector();
    Words.add(new String("HELLO"));
    Words.add(new String("GOOD BYE"));
    // When I try to get a string from the Vector I use this.
    // The program compiles but when I try to run it I get NullPointerExeption here
    W = (String) Words.elementAt(0);

    Not sure since I cant see all of your code but looks like this might be your problem:
    // First I define it.
    Vector Words; //<-- here you define a Vector named Words that is null
    // Then add the words
    Vector Words = new Vector(); //<-- here you define another vector named Words that holds a reference to a new Vector. This is a different reference than the one created above so you should probably remove the "Vector" part from the beginning of this line. Is this a local variable to a method and the one before is a global variable?
    //Here you probably access the locally created Words vector which is initialized
    Words.add(new String("HELLO"));
    // When I try to get a string from the Vector I use this.
    // The program compiles but when I try to run it I get NullPointerExeption here
    W = (String) Words.elementAt(0); //<--and here my guess is that this statement is inside another method than the one with the local Words vector defined. Thus this one accesses the global Words Vector that is never initalized and is Null. And that gives you the NullPointerException.
    So try changing the statement
    Vector Words = new Vector();
    to
    Words = new Vector();
    or just remove it totally and move the Vector creation to the place where you introduce the global variable.
    Of course I might be totally wrong since I cant see all of your code but that is my guess.
    Hope it helps,
    -teka

  • StringTokenizer class problem with strings in double quotes

    Hello Technocrats,
    I have a problem with tokenizing following string enclosed in (). (abc," India, Asia", computer engineer). My separator is ",", thus StringTokenizer class gives me 4 tokens namely abc, "India, Asia" and computer engineer. But I require that String in double quotes should be a single token. How to achieve this using StringTokenizer class? Or is there any other way?
    Thanks in advance.

    Try
    String[] str="abc,\" India, Asia\",computer engineer".split(",",1);
              for(String s: str)
                   System.out.println(s);
              }Thanks.

  • Compile problem with javax.sql

    I have upgraded to sdk 1.4.2 and tried to compile my code. I am getting an error on import javax.sql.* where I am getting the message "Package does not exist" error. As the result of this any class that is in this package gets an error as well. I am using ant to do the build. It does not seem to have a problem with the other import files and some of my code do compile fine except for this one that contains javax.sql.*. Thanks for your help.

    Are you sure that the javax.sql.* stuff exists in your javac classpath? It seems not to be there. Look for j2ee.jar (from Sun J2EE SDK), or something like that (something like it probably came with your app server).
    Mike

  • Compiler Problem with double. Need Help

    Hello,
    I am having a problem with WorkShop Compilers 5.0 98/12/15 C++ 5.0. There is a problem with declaring double inside a nested class which is nested 3 times. Below is the code what shows the problem. If you have Workshop 5.0 please cut and paste the program below and do a simple cc <filename> compile. Run it and you should see the problem.
    ---------------------------cut----------------------------
    #include <stdio.h>
    class myclass3
    public:
    myclass3() {}
    ~myclass3() {}
    short aaa;
    int bbb;
    double ccc;
    char ddd;
    class myclass2
    public:
    myclass2() {}
    ~myclass2() {}
    short aaa;
    int bbb;
    double ccc;
    char ddd;
    myclass3 m_myclass3[50];
    class myclass
    public:
    myclass() {}
    ~myclass() {}
    int a;
    char b;
    float c;
    short aa;
    double bb;
    myclass2 m_myclass2;
    int main()
    myclass m_myclass;
    m_myclass.m_myclass2.m_myclass3[1].ccc = 11111.1111;
    printf("<%f>\n",m_myclass.m_myclass2.m_myclass3[1].ccc);
    return 0;
    ---------------------------cut----------------------------
    The result I get on my machine is
    <-3100025845628125216032986949222617505819484589120973946744108811398502585541238252995581839380933130321904775653231251529249013141831370896782391931299571941247444654355877793201472387703486841059940760873131775588361546584668766208.000000>
    This is definitly incorrect. Does anyone have this problem? Is this a compiler bug? If you figure it out please email me at [email protected]
    Thanks
    Salman Ahmad

    Salman - I tested your program on an up to date version of the C++
    5.0 compiler and received the following results:
    a.out<11111.111100>
    That is what I would expect...
    Have you installed all of the patches for the 5.0 compiler? It is
    possible that this problem was found and fixed.
    The current basic patchid's for CC 5.0 on sparc are: 107311-12, 107357-11, and the libC patch for your version of the OS.

  • Compiling problem with 1.4

    my code is compiling well in 1.3 and the same is giving error if i compile with 1.4 compiler. pls help me out. here is the sample code which compiles fine with 1.3 and gives error in 1.4.
    String lv_str_AdvPay = (String).valueOf(lv_db_AdvPay);
    -atthuluri

    my code is compiling well in 1.3 and the same is
    giving error if i compile with 1.4 compiler. pls help
    me out. here is the sample code which compiles fine
    with 1.3 and gives error in 1.4.
    String lv_str_AdvPay =
    (String).valueOf(lv_db_AdvPay);What's the error message? And what's the context of the code - what type is lv_db_AdvPay?
    Regards,
    Bhaveet

  • JSP Compilation Problems With JSTL tags

    My JSP worked well when I used JSP expressions, scriptlets, .... I tried to use JSTL instead and encountered some compilation problems. I am unable to see my mistakes and need help:
    Problme #1:
    int offset = 0;
    try
       <c:set var="offset" value="${requestScope.offset}" />
    catch ( Exception e )
        // do nothing
    }The above code has two compilation errors:
    Generated servlet error:
    [javac] Compiling 1 source file
    illegal start of expression
    <c:set var="offset" value="${requestScope.offset}" />
    ^
    Generated servlet error:
    ';' expected
    <c:set var="offset" value="${requestScope.offset}" />
    ^
    Problem #2:
    <c:set var="threadBean" value="${requestScope.ThreadBean}" />
    int threadID_int = ParamUtil.getParameterInt( request, "thread" );
    <c:if test="${threadBean.threadID} != threadID_int">
        throw new AssertionException( "The two threadID are not the same." );
    </c:if>Generated servlet error:
    illegal start of expression
    <c:if test="${threadBean.threadID != threadID_int}">
    ^

    I have deleted the Java code around the JSTL tags. Now, what is wrong with this <c:if test=" ... "> tag? It seems that I have problems to get JSTL tags right.
    It seems that I have problems to get JSTL tags right....
    <c:if test="${attachBean.attachMimeType.startsWith('image/')}">
         <html:img page="getattachment?attach=<c:out value='${attachBean.attachID}' />" alt="<c:out value='${attachBean.attachFilename}' />" title="<c:out value='${attachBean.attachFilename}' />" border="0" />
    </c:if>error message:
    74: tag = 'if' / attribute = 'test': An error occurred while parsing custom action attribute "test" with value "${attachBean.attachMimeType.startsWith('image/')}": Encountered "(", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||"]

  • Compiling Problem With Command Line

    I am facing problem to compile the following class:
    the error code is Like the following :
    Sorry, I was trying to understand the members of a class declaration
    but I got confused when I saw 'var' which is a keyword.var city: String;
    {color:#ff0000}class Address {
    var city: String;
    }{color}
    But when i compile the following class there was no error.
    {color:#339966}class Address {
    attribute city: String;
    }{color}
    Ok I consider that it takes attribute key word.
    But in NetBeans 6.5 The following code is OK
    {color:#339966}class Address {
    var city: String;
    }{color}
    Could Any One tell me where is the problem.
    With Best Regards
    A S M Russel.
    Edited by: Russel8930 on Dec 9, 2008 2:25 PM
    Edited by: Russel8930 on Dec 9, 2008 2:28 PM

    You have two different versions of the compiler on your machine. The right syntax is the one with the var-keyword.

  • Problems with string tokenizer

    okay heres my problem, i have a textarea displaying a program listing and i have to extract variables i.e public int something;
    i have tried many different approaches but still the output is not what i was looking for. Can someone have a look at my code and check for mistakes that i cant find
    public void createDataDictionary() {
              if(fullText.equals("")) return;//do nothing if no text exists
              String checkText = fileContents.getText();//store text area contents into string
              String dataType = "";
              String variable = "";
              String accessModifier = "";
              StringTokenizer str = new StringTokenizer(checkText," \n", true);
              fileCheckBox.setText("");//clear file check box
              while(str.hasMoreTokens()) {//loop while there are more tokens to tokenize
                   try{                    
                        checkText = str.nextToken();
                        //check for comments
                        if((checkText.startsWith("//")) || (checkText.equals("//")) ||
                           (checkText.startsWith("/**")) || (checkText.equals("/**")) ||
                           (checkText.startsWith("*")) || (checkText.equals("*"))) {
                             isComment = true;                    
                        if((checkText.equals("\n"))) isComment = false;
                        if(!isComment)
                             //check for access modifiers
                             if((checkText.equals("public")) || (checkText.equals("private")) ||
                                (checkText.equals("protected"))) {
                                          accessModifier = checkText;
                                     }else {
                                          accessModifier = "";
                             //check for data types             
                             if((checkText.equals("boolean")) || (checkText.equals("char")) ||
                                     (checkText.startsWith("String")) || (checkText.equals("int"))) {
                                       dataType = checkText;
                                       variable = str.nextToken();//get variable expression
                                       System.out.println(accessModifier + " " + dataType + " " + variable);
                   }catch(NoSuchElementException nsee) {//not enough tokens to complete operation
                        JOptionPane.showMessageDialog(null, "End of file");
                        return;//break from method
         }here is sample text
    private String seven = "help";
    char five[];
    // String here
    //int found
    public boolean okay
    and here is the output
    String
    char
    String
    boolean
    //note the space before each output
    hope someone can help
    thanx in advance

    1. Why do you check to see if the token starts with
    //, /*, etc, etc. Later you check if the token
    equals private, public, protected. It couldn't
    equal if it started with a comment.if the token starts with a comment i dont want to read the rest of the line, so i set the isComment flag to true
    2. I strongly suggest that you do it line by line.
    Perhaps a string tokenizer that only tokenizes by
    lines, then within that loop, another that tokenizes
    by whitespace. i take it you mean putting the text into a bufferedreader and then using readLine()?? Bit new to string tokenization as you can possibly see
    i managed to get the small test text to work more or less as i wanted but when ever i load a large code listing, the results are erratic to say the least
    heres a section of this code
    private int textNum = 0;/**Integer used to hold the text position within any given line*/
         private int lineNum = 0;/**Integer used to hold the line number within any given file*/
         static boolean application = false;/**Used to track if applet is ran from a browser or JAR file*/
         static boolean fileOpened = false;/**Used to track if file has already been opened*/
         static boolean isComment = false;
         private char lCurve = '(';
         private char rCurve = ')';
         private char lCurly = '{';
         private char rCurly = '}';
         private char lSquare = '[';
         private char rSquare = ']';
         String fullText = "";and heres the output
    public int textNum //should be private!!!!
    int lineNum //missing private
    boolean application //missing static
    boolean fileOpened //missing static
    boolean isComment //missing static
    //all below missing private     
    char lCurve
    char rCurve
    char lCurly
    char rCurly
    char lSquare
    char rSquare
    String fullText //not there at all

  • Problems with String

    Hey All,
    I have this string "Straw? No, too stupid a fad, I put soot on warts" I am going to test is this string is a palindrome. Thi string is, but I run it through my program it says it is not because of the "?" and ",". How to take that string run it through something like a buffer or tokenizer to take out those things like "?" , "," and anything else. In the end I would like to have to remove all those types of characters and just run a string into the like I want to above to me change to this
    From:
    Straw? No, too stupid a fad, I put soot on warts
    To:
    Straw No too stupid a fad I put soot on warts

    You have to place a space in the replace(' ',' ') or it will not work. Plus it does not work with that, it just adds a space to what ever characeter I just replaced. Would a Stringtokenizer with a space delimiter take of my problem?

Maybe you are looking for

  • Mid 2014 15" Retina Macbook Pro Bootcamp Windows 8.1

    Okay, so this is part question and part rant. The question part: Has anyone successfully installed windows 8.1 in bootcamp on a mid2014 Macbook pro? The rant part: This new macbook is awesome. Everything is great. Except that apple needs to get their

  • Adobe Reader 9 freezes up my pc on 'close'

    I have been having problems in closing down the internet by using the 'X' in the top right hand corner of the screen. It would start to close, then I'd get a pop-up message stating something like"Microsoft has encountered a problem and needs to close

  • Need help restoring a C: (boot) drive on a client computer

    What is the best way to restore the c: drive on a client computer?  The SSD died so I have to start with a new drive.  Can I plug the new drive into another client that is working and restore the drive from there?  Or, do I need to install the OS on

  • How do I enable file auto-locking in 10.9?

    Back in Lion, files would lock after a short time, so they were read-only. I actually prefer that behavior, but Mavericks does not do that by default. What are the magic steps to bring this back? Thanks in advance.

  • Java class does not complie

    Hello experts: I am compiling a sample jdbc program using jdk1.1.8 in windows 95. The sample programs that i am compiling are in Oracle_home\ jdbc\samples directory. I have the jdbc/lib/classes111.zip in my C:\path. Any comments I get the following e