Witam serdecznie
Piszę do Was, ponieważ spotkałem się z dziwnym zdarzeniem. Mój program działa jak chcę, cacy i w ogóle, ale zacząłem go pisać w gcc, a skończyłem w MSVC.
Chodzi o wspomnianą w tytule interpretację definicji funkcji.
Funkcja InsertionSort wywala mi w gcc błąd
error: conflicting types for ‘InsertionSort’
note: previous declaration of ‘InsertionSort’ was here
Natomiast w MSVC tego nie ma
Problem pojawił się, kiedy zmieniłem w definicji funkcji:
float InsertionSort(int *result, int *amount);
na
float InsertionSort(int **result, int *amount);
Oczywiście w obydwu plikach
Czy macie jakiś pomysł jak to wyjaśnić?
Przesyłam kod, chociaż nie wiem, czy cokolwiek pomoże.
Pozdrawiam.
header:
#ifndef HEADER_H
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define LIMIT 10000
int *Random(int *amount);
float ShellSort(int *amount);
float InsertionSort(int **result, int *amount);
#endif // HEADER_H
InsertionSort
#include "header.h"
float InsertionSort(int **result, int *amount)
{
clock_t start;
int i, k, temp;
static unsigned int operations;
start = clock();
for (i = 1; i < *amount; i++)
{
temp = *result[i];
for (k = i - 1; k > -1; k--)
{
if (temp < *result[k])
{
*result[k + 1] = *result[k];
operations++;
}
else
break;
}
*result[++k] = temp;
operations++;
}
start = clock() - start;
return ((float)start) / CLOCKS_PER_SEC;
}