Sun Studio 10 issue

This is a discussion on Sun Studio 10 issue within the C Programming forums, part of the General Programming Boards category; Hi, The company has just bought Sun Studion 10 for a new development environment, whereas before I was using Sun ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    38

    Sun Studio 10 issue

    Hi,
    The company has just bought Sun Studion 10 for a new development environment, whereas before I was using Sun Workshop 3. Unfortunately there are differences in the way that the two compilers and while not completly failing it is throwing up some very odd error messages. For example it does not seem to like the continuation character "\" (backslash) when used to continue a statement onto a new line.
    The code below is the first part of a fprintf statement
    Code:
     
    fprintf (LogFileHandle, "01 Processed\n\
    ------------\n\
    Crystal Records  %d\n\
    Arbor Records    %d\n\
    SSBS Records     %d\n\
    Total            %d\n\n\
    02 Processed\n\
    ------------\n\
    Crystal Records  %d\n\
    Arbor Records    %d\n\
    SSBS Records     %d\n\
    Total            %d\n\n\
    02 Written Out\n\
    -----------\n\
    Crystal Records  %d\n\
    Arbor Records    %d\n\
    SSBS Records     %d\n\
    Total            %d\n\n\
    02 Ignored (Not Live)\n\
    --------------------\n\
    When you compile this you get the following warning:

    "billing_data_merge.c", line 424: newline in string literal
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: operand must be of integer, real or pointer type : op "--"
    "billing_data_merge.c", line 425: invalid source character: '\'
    "billing_data_merge.c", line 425: syntax error before or at: n
    "billing_data_merge.c", line 425: invalid source character: '\'
    "billing_data_merge.c", line 426: invalid source character: '\'
    "billing_data_merge.c", line 426: invalid source character: '\'
    "billing_data_merge.c", line 427: invalid source character: '\'
    etc

    where the fprintf is on line 424. I cannot think why it is complaining about this, the code has not changed and the previous compiler handled it fine. I have tried various combinations of the -X[a|c|t|s] which turns on and off K&R and ISO compliance, but these do not have any effect.
    Any ideas anyone?
    Thanks

  2. #2
    Registered User
    Join Date
    Jul 2005
    Location
    Transcarpathia
    Posts
    49
    Code:
    char str[] = "this "
       "will "
       "be "
       "concatenated "
      ". No backslashed needed";

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The backslash for "multiple lines" is for use in macros. Such as:
    Code:
    #define FOO(x) (x) > 10 ? 5 \
        : (x) > 7 ? 3 \
        : (x) > 4 ? 1 : 0

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    38
    Valenok,
    Thanks for the reply. Basically you are saying I need to edit all my code to remove the backslashes, but the format can remain the same?
    Oh bugger. Thats not a small job.
    Thanks

  5. #5
    Registered User
    Join Date
    Jul 2005
    Location
    Transcarpathia
    Posts
    49
    it is not that hard.
    small shell script will do the job for you.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    It's just one of those occupational hazards when it comes to porting code, where the programmer relied on "what the compiler will let me get away with", rather than "learning ANSI-C so that it will stand a passing chance on all compilers".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  2. Array help
    By Oklaskull in forum C Programming
    Replies: 19
    Last Post: 03-11-2008, 04:15 PM
  3. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  4. Heaps...
    By Nutshell in forum C Programming
    Replies: 14
    Last Post: 04-23-2002, 08:54 AM
  5. Formatting Output
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 03-26-2002, 12:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21