Hi,
please look at this code:
void speichere_messoptionen(int i, int iAction) { int Opt_Datei; Opt_Datei = OpenFile ("nmv_opt.opt", VAL_WRITE_ONLY, iAction, VAL_ASCII); FmtFile(Opt_Datei,"***%s %i. Aufruf ***", "speichere_messoptionen",i); /*Einlesen der Optionen zum Messen*/ WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 2); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%f", 3.0); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 4); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 5); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 6); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 7); WriteFile (Opt_Datei, "\n",1); FmtFile(Opt_Datei,"%i[b2]", 8); WriteFile (Opt_Datei, "\n",1); CloseFile (Opt_Datei); } void lese_messoptionen(void) { int Opt_Datei; int ret = 0; Opt_Datei = OpenFile ("nmv_opt.opt", VAL_READ_ONLY, VAL_TRUNCATE, VAL_ASCII); //bug ret = ReadFile (Opt_Datei, "\n", 1); // lese ein Zeichen ohne buffer CloseFile (Opt_Datei); } int main (int argc, char *argv[]) { int i = 0; if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ //erster Aufruf der Funktion mit Aktion TRUNCATE speichere_messoptionen(1, VAL_TRUNCATE); //hier bug verursachen lese_messoptionen(); //zweiter Aufruf der Funktion allerding mit Append (Aktion ist eigentlich egal, dann habe ich den Fehler aber in einer Datei ;-) speichere_messoptionen(2, VAL_APPEND); return 0; }
ouput with CVI 2013 SP1 is:
***speichere_messoptionen 1. Aufruf *** 2 3.0 4 5 6 7 8 ***speichere_messoptionen 2. Aufruf ****2*3.0*4*5*6*7*8*
output with CVI 2009 is:
***speichere_messoptionen 1. Aufruf *** 2 3.0 4 5 6 7 8 ***speichere_messoptionen 2. Aufruf *** 2 3.0 4 5 6 7 8
The error happens in lese_messoptionen ReadFile(Opt_Datei, "\n",1); It's wrong to use "\n". Old software, sleeping bug :smileywink:
Is it a CLANG feature or a CLANG bug?
Regards,
Thomas