Ciao a tutti
Sto creando delle piccole automazioni per un programma e ho qualche problemino con il mio codice che in fase di compilazione mi da dei "Waning"
Questo è il mio codice:
#include <ae/ae.h>
#include <stdlib.h>
#include <tccore/aom.h>
#include <tc/emh.h>
#include <ict/ict_userservice.h>
#include <tc/tc.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
#include <stdio.h>
#include <string.h>
#define ECHO(X) printf X; TC_write_syslog X
#define IFERR_ABORT(X) (report_error( __FILE__, __LINE__, #X, X, TRUE))
#define IFERR_REPORT(X) (report_error( __FILE__, __LINE__, #X, X, FALSE))
#define IFERR_RETURN(X) if (IFERR_REPORT(X)) return
static int report_error(char *file, int line, char *call, int status,
logical exit_on_error)
{
if (status != ITK_ok)
{
int
n_errors = 0,
*severities = NULL,
*statuses = NULL;
char
**messages;
EMH_ask_errors( &n_errors, &severities, &statuses, &messages );
if (n_errors > 0)
{
ECHO(("\n%s\n", messages[n_errors-1]));
EMH_clear_errors();
}
else
{
char *error_message_string;
EMH_get_error_string (NULLTAG, status, &error_message_string);
ECHO(("\n%s\n", error_message_string));
}
ECHO(("error %d at line %d in %s\n", status, line, file));
ECHO(("%s\n", call));
if (exit_on_error)
{
ECHO(("\nExiting program!\n"));
exit (status);
}
}
return status;
}
typedef struct {
double aimkey;
char* short_descr;
char* long_descr;
char* create_user;
char* tipologia_progetto;
//double tipologia_progetto;
char* tipo_macchina;
char* serial_number;
char* linea_macchina;
char* classificazione;
char* ident;
} Owner;
Owner owners[300];
int load(char* filename)
{
char buffer[2000];
Owner* owner;
(*owner)=0;
int owners_size = 0;
FILE* file = fopen(filename, "r");
while (fgets(buffer, 2000, file) != NULL)
{
owner = (Owner *)malloc(sizeof(Owner));
owner->aimkey = atof(strtok(buffer, ";"));
//owner->aimkey = strdup(strtok(NULL, ";"));
owner->short_descr = strdup(strtok(NULL, ";"));
owner->long_descr = strdup(strtok(NULL, ";"));
owner->create_user = strdup(strtok(NULL, ";"));
//owner->tipologia_progetto = atoi(strtok(buffer, ";"));
owner->tipologia_progetto = strdup(strtok(NULL, ";"));
owner->tipo_macchina = strdup(strtok(NULL, ";"));
owner->serial_number = strdup(strtok(NULL, ";"));
owner->linea_macchina = strdup(strtok(NULL, ";"));
owner->classificazione = strdup(strtok(NULL, ";"));
owner->ident = strdup(strtok(NULL, ";"));
owners[owners_size++] = *owner;
}
fclose(file);
return owners_size;
}
char *strdup(const char *str)
{
size_t len = strlen(str) + 1;
char *dup = malloc(len);
if (dup != 0)
memmove(dup, str, len);
return(dup);
}
static void do_it(void)
{
tag_t
folder_type_tag = NULLTAG,
rev_type_tag = NULLTAG,
folder_create_input_tag = NULLTAG,
itemrev_create_input_tag = NULLTAG,
folder_tag = NULLTAG;
char
*sr4_Sottotipo_prop[] = {"Prova_scrittura1"},
*owners_filename = "C:\\Siemens\\TC10\\tcroot\\tc_menu\\Cartel1.csv";
int
owners_size, index;
owners_size = load(owners_filename);
printf("owner size %d\n",owners_size);
if(owners_size)
{
for(index = 0; index < owners_size; index++)
printf("short_descr:%c\n",owners[index].short_descr);
printf("long_descr:%c\n",owners[index].long_descr);
printf("tipo_macchina:%c\n",owners[index].tipo_macchina);
printf("linea_macchina%c\n",owners[index].linea_macchina);
printf("classificazione:%c\n",owners[index].classificazione);
{
IFERR_ABORT(TCTYPE_find_type("SR4_ProjectFolder", NULL, &folder_type_tag));
IFERR_ABORT(TCTYPE_construct_create_input (folder_type_tag, &folder_create_input_tag));
printf("DEBUG 1\n");
IFERR_ABORT(TCTYPE_set_create_display_value( folder_create_input_tag, "object_name", 1, owners[index].short_descr ));
printf("DEBUG 2\n");
IFERR_ABORT(TCTYPE_set_create_display_value(folder_create_input_tag, "object_desc", 1, owners[index].long_descr ));
IFERR_ABORT(TCTYPE_set_create_display_value(folder_create_input_tag, "sr4_TipoMacchina",1, owners[index].tipo_macchina ));
IFERR_ABORT(TCTYPE_set_create_display_value(folder_create_input_tag, "sr4_LineaMacchina",1, owners[index].linea_macchina ));
IFERR_ABORT(TCTYPE_set_create_display_value(folder_create_input_tag, "sr4_Classificazione",1, owners[index].classificazione ));
IFERR_ABORT(TCTYPE_set_create_display_value(folder_create_input_tag, "sr4_Sottotipo",1, sr4_Sottotipo_prop ));
printf("DEBUG 3\n");
IFERR_ABORT(TCTYPE_create_object(folder_create_input_tag, &folder_tag ));
IFERR_ABORT(AOM_save(folder_tag));
printf("DEBUG 4\n");
}
}
printf("THE WINNER IS..!");
}
int ITK_user_main(int argc, char* argv[])
{
IFERR_REPORT(ITK_initialize_text_services(ITK_BATCH_TEXT_MODE));
IFERR_ABORT(ITK_auto_login());
IFERR_REPORT(ITK_set_journalling(TRUE));
do_it();
IFERR_REPORT(ITK_exit_module(FALSE));
return ITK_ok;
}
Quando lancio il compilatore ho questi messaggi:
create_custom_folder_csv.c(103) : warning C4273: 'strdup' : inconsistent dll lin
kage
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\\include\string.h
(238) : see previous definition of 'strdup'
create_custom_folder_csv.c(148) : warning C4047: 'function' : 'const char **' di
ffers in levels of indirection from 'char *'
create_custom_folder_csv.c(148) : warning C4024: 'TCTYPE_set_create_display_valu
e' : different types for formal and actual parameter 4
create_custom_folder_csv.c(150) : warning C4047: 'function' : 'const char **' di
ffers in levels of indirection from 'char *'
create_custom_folder_csv.c(150) : warning C4024: 'TCTYPE_set_create_display_valu
e' : different types for formal and actual parameter 4
create_custom_folder_csv.c(151) : warning C4047: 'function' : 'const char **' di
ffers in levels of indirection from 'char *'
create_custom_folder_csv.c(151) : warning C4024: 'TCTYPE_set_create_display_valu
e' : different types for formal and actual parameter 4
create_custom_folder_csv.c(152) : warning C4047: 'function' : 'const char **' di
ffers in levels of indirection from 'char *'
create_custom_folder_csv.c(152) : warning C4024: 'TCTYPE_set_create_display_valu
e' : different types for formal and actual parameter 4
create_custom_folder_csv.c(153) : warning C4047: 'function' : 'const char **' di
ffers in levels of indirection from 'char *'
create_custom_folder_csv.c(153) : warning C4024: 'TCTYPE_set_create_display_valu
e' : different types for formal and actual parameter 4
Ho cercato in più modi di risolverli ma senza alcun risultato. Qualcuno saprebbe darmi delle dritte?!
Vi ringrazio anticipatamente.
Francesco