Data:
double DaysEarthSun[][10] ={
// 0 1 2 3 4 5 6 7 8 9
// JDTDB, Calendar Date (TDB), X, Y, Z, VX, VY, VZ, LT, RG, RR,
{2305447.500000000, /*"A.D. 1600-Jan-01 00:00:00.0000",*/ -2.568497981915648E-01, 9.438245451677045E-01, 6.410938668761658E-04, -1.684598702834566E-02, -4.667597482526307E-03, -4.906040833845624E-06, 5.649322014152373E-03, 9.781497849989120E-01, -8.026158042429985E-05},
{2305448.500000000, /*"A.D. 1600-Jan-02 00:00:00.0000",*/ -2.736541829631095E-01, 9.390104932363517E-01, 6.360724040092633E-04, -1.676196451434489E-02, -4.960286450217222E-03, -5.142448255071298E-06, 5.648881285390255E-03, 9.780734751792867E-01, -7.236940265538736E-05}
}
Funkce:
#define foreach(item, array) \
for(int keep = 1, \
count = 0,\
size = sizeof (array) / sizeof *(array); \
keep && count != size; \
keep = !keep, count++) \
for(item = (array) + count; keep; keep = !keep)
void printSOE(){
// double * soe;
double distance, velocity, km, km_2, speed;
FILE *f;
foreach(double *soe, DaysEarthSun) {
// soe = DaysEarthSun[*v];
distance = sqrt( soe[1]*soe[1] + soe[2]*soe[2] + soe[3]*soe[3] ); // units: AU-D
velocity = sqrt( soe[4]*soe[4] + soe[5]*soe[5] + soe[6]*soe[6] ); // units: AU-D
km = (149597870.700*distance); // km/day
speed = (149597870.700*velocity); // km/day
km_2 = 25902068370*soe[7]; // E-S distance: light day to km
printf("\n\n%f km , %f km/day\n", km, speed);
printf("distance based on light: %f km/day\n\n", km_2);
f = fopen("output.txt", "a");
fprintf(f, "%f, %f,", km, speed );
}
fclose(f);
}
warning: initialization from incompatible pointer type [enabled by default]|
Tím se odkazuje na foreach(double *soe, DaysEarthSun) {
soe má být řádek s daty; makro má nahradit foreach(array => item)
Pole DaysEarthSun jsem původně přiřadil tomu double * soe a bez foreach to fungovalo, ale když jsem to dal dovnitř foreach tak už to hlásí tuhle hlášku.
Edit:
Ta chyba souvisí s double *soe, původně tam bylo int *soe ale to taky nepomohlo.