Problem when compiling pointers with GNU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all.

I have compiled simple code with GNU compiler 2.95.3 under Cygwin and run the produced ANSI-C code on a Motorola 68040 witch works fine. Now I want to make the code more advanced by using pointers. When I try to compile code like attached with GNU compiler 2.95.3 under Cygwin the compilation is passed without errors. But when I run the produced code on the Motorola 68040 the pointer usage seems not to work. In fact the variable A8_DMD_LAG_ST is not initialized to 8 as wanted when AS_INIT is 1 the first loop. Also the value of A8_DMD_LAG_ST is after that constant witch is not intended. For me it seems like something with the pointer usage is the problem. But I can?t recognize what. Is there a flag or setting to be changed in GCC compiler to compile pointers correctly for the processor?

The code works fine with visual c++ v6. Note that the code do not look exactly like attached when compiled with GNU. It is the use of the pointers that is of interest and not working.

Can someone please help me?

Thankful for help.

/Johan Larsson



program.c:


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <be_ca8cdmds.h>


void main(void){

int i;

bool AS_INIT=1;



float MAX_13_1_1[10]={10,9,8,7,6,5,4,3,2,1};
static float A8_DMD_LAG_ST ;

int *iinfo = &I->iinfo[0];
float *rinfo = &I->rinfo[0];

struct _CA8CDMDS_ps *X = &S->CA8CDMDS_ps[S->CA8CDMDS_x];
struct _CA8CDMDS_ps *XD = &S->CA8CDMDS_ps[1-S->CA8CDMDS_x];
const float TSAMP   = rinfo[1];

for(i=0;i<10;i++){

 if( AS_INIT ) {

      A8_DMD_LAG_ST2 = 8.0;
 }

 if ( AS_INIT ) {
        I->A8_DMD_LAG_ST2 = &A8_DMD_LAG_ST2;
 }
 if( AS_INIT ) {
        X->CA8CDMDS_97_S1 = 0.0;
        X->A8_DMD_LAG_ST_S = 0.0;
        XD->CA8CDMDS_97_S1 = 0.0;
        XD->A8_DMD_LAG_ST_S = 0.0;
        X->A8_DMD_LAG_ST_S = (*I->A8_DMD_LAG_ST2);
 }

 if (AS_INIT && XREMAP) {
        X->A8_DMD_LAG_ST_S = X->A8_DMD_LAG_ST_S - TSAMP*MAX_13_1_1[i];
 }

 XD->A8_DMD_LAG_ST_S = X->A8_DMD_LAG_ST_S + TSAMP*MAX_13_1_1[i];


 A8_DMD_LAG_ST = XD->A8_DMD_LAG_ST_S;

 printf("%f  ",A8_DMD_LAG_ST);

 AS_INIT=0;


 }

}



be_ca8cdmds.h:



int XREMAP = 1;

float A8_DMD_LAG_ST2;

#ifndef _CA8CDMDS_H_
#define _CA8CDMDS_H_
#ifndef CA8CDMDS_STRUCTS
#define CA8CDMDS_STRUCTS


struct _CA8CDMDS_ps {
  float CA8CDMDS_97_S1;
  float A8_DMD_LAG_ST_S;
};

struct _CA8CDMDS_s {
  struct _CA8CDMDS_ps CA8CDMDS_ps[2];
  int CA8CDMDS_x;
};

struct _CA8CDMDS_info {
  int iinfo[5];
  float rinfo[5];
  float *A8_DMD_LAG_ST2;
};


struct _CA8CDMDS_info struct_I = {{0,1,0,0,0},{0.00,0.05,0.00,0.00,0.00}};
static struct _CA8CDMDS_info *I = &struct_I;

struct _CA8CDMDS_s struct_S;
static struct _CA8CDMDS_s *S = &struct_S;
#endif

static float A8_MIN_SCH_N;
static float A8_DOT_PS3_GAIN_N;
static float A8_DOT_PS3_BIAS_N;
static float A8_DOT_PS3_MAX_N;
static float A8_DOT_PS3_NEG_N;
static float ZA8_FLR_MOV_WFR_N;

#endif

_________________________________________________________________
Idolerna uppträder på MSN http://msnpresents.msn.com/hub/?mkt=sv-se


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux