Thread: gcc compiler error under MacOs 10.7.3

Started: 2012-03-31 17:03:04
Last activity: 2013-03-14 21:36:40
Topics: SAC Help
LeRoy Dorman
2012-03-31 17:03:04
Attempting to compile sac-101.5c using gcc version i686-apple-darwin11-llvm-gcc-4.2 under Macos 10.7,3,
I get a series of compiler errors stemming from the following code in hdr.h

I want to compile this so I can run SAC under the debugger to track down problems.

gcc -DHAVE_CONFIG_H -I. -I../inc -I../inc -I../libedit/include -DDOINITS -c ./dff/hdrfld.c -o dff/hdrfld_io.o
In file included from ./dff/hdrfld.c:12:
../inc/hdr.h:287: error: initializer element is not constant
../inc/hdr.h:288: error: initializer element is not constant
../inc/hdr.h:289: error: initializer element is not constant

The offending lines follow the ifdef below.


#ifdef DOINITS
float *const a = (float*)((char*)cmhdr.fhdr + 32);
float *const arrivl = (float*)((char*)cmhdr.fhdr + 32);
float *const az = (float*)((char*)cmhdr.fhdr + 204);
And many more follow.

Is there an easy way to fix this?

I am neither a skilled C coder nor Mac user.

LeRoy Dorman

  • Hongfeng Yang
    2013-03-14 21:36:40
    I am not sure whether someone has already responded to this compilation
    error. Sorry for duplicated posting if there was an answer.

    The problem is the version of gcc coming with OSX is too old. I had the
    same error using gcc-4.2. The solution is simply to use a newer gcc such
    as "./configure --prefix=/opt/sac101.4 CC=/sw/bin/gcc-4" with gcc
    version 4.6.3 (GCC).

    Hongfeng


    On 3/31/12 6:03 AM, Dorman, Leroy wrote:
    Attempting to compile sac-101.5c using gcc version
    i686-apple-darwin11-llvm-gcc-4.2 under Macos 10.7,3,
    I get a series of compiler errors stemming from the following code in
    hdr.h

    I want to compile this so I can run SAC under the debugger to track
    down problems.

    gcc -DHAVE_CONFIG_H -I. -I../inc -I../inc
    -I../libedit/include -DDOINITS -c ./dff/hdrfld.c -o dff/hdrfld_io.o
    In file included from ./dff/hdrfld.c:12:
    ../inc/hdr.h:287: error: initializer element is not constant
    ../inc/hdr.h:288: error: initializer element is not constant
    ../inc/hdr.h:289: error: initializer element is not constant

    The offending lines follow the ifdef below.


    #ifdef DOINITS
    float *const a = (float*)((char*)cmhdr.fhdr + 32);
    float *const arrivl = (float*)((char*)cmhdr.fhdr + 32);
    float *const az = (float*)((char*)cmhdr.fhdr + 204);
    And many more follow.

    Is there an easy way to fix this?

    I am neither a skilled C coder nor Mac user.

    LeRoy Dorman


    _______________________________________________
    sac-help mailing list
    sac-help<at>iris.washington.edu
    http://www.iris.washington.edu/mailman/listinfo/sac-help


    --
    Postdoctoral Investigator
    Department of Geology and Geophysics
    Woods Hole Oceanographic Institution
    360 Woods Hole Rd, MS 24
    Woods Hole, MA 02543


11:14:25 v.01697673