Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

05.09.2009, 15:19

Listing 8.8 Problem unter Visual C++ 2008 EE

Hi,

Ich hab das Listing wie folgt abgetippt:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// C++ für Spieleprogrammierer

// Listing 8.8

// Dateien: Ein- und Ausgabe

//

#include <iostream>
#include <fstream>

using namespace std;

// Hauptprogramm

//

int main ()
{
    // Variablen

    //

    int Highscore = 0;

    // Aktuellen Highscore abfragen

    cout << "Wie hoch ist der Highscore: ";
    cin >> Highscore;

    // Datei zum Schreiben öffnen und Highscore hineinschreiben

    ofstream Output ("Highscore.hsc", ios::binary);
    Output.write ((char*) &Highscore, sizeof (Highscore));

    // Datei schließen

    Output.close ();

    // Neues Spiel, neues Glück. Highscore zurücksetzen

    Highscore = 0;

    // Datei zum Lesen öffnen und highscore auslesen

    ifstream Input ("Highscore.hsc", ios::binary);
    Input.read ((char*) &Highscore, sizeof (Highscore));

    // Datei schließen ;)

    Input.close ();

    // Highscore ausgeben

    cout << "Highscore aus der Datei: " << Highscore;
    cout << endl;

    cin.get ();

    return 0;
}



Mit der Ausnahme, dass ich "cin.get ()" drangehängt habe.

Ich erhalte nun folgende Fehlermeldung:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1>------ Erstellen gestartet: Projekt: Listing 8.8, Konfiguration: Debug Win32 ------
1>Kompilieren...
1>Listing 8_8.cpp
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(1) : error C2470: "h": Sieht wie eine Funktionsdefinition aus, es ist aber keine Parameterliste vorhanden; sichtbarer Funktionstext wird übersprungen.
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(1) : error C2059: Syntaxfehler: '>'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(8) : warning C4081: ')' erwartet; 'Zeichenfolge' gefunden
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(10) : error C2143: Syntaxfehler: Es fehlt ';' vor '{'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(10) : error C2447: '{': Funktionsheader fehlt - Parameterliste im alten Stil?
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(13) : warning C4002: Zu viele übergebene Parameter für das Makro '_crt_va_start'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(76) : warning C4068: Unbekanntes Pragma
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(76) : error C2018: Unbekanntes Zeichen '0x8'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(76) : error C2018: Unbekanntes Zeichen '0x60'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(104) : fatal error C1070: Fehlende Zuordnung von #if und #endif in Datei "c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl"
1>Das Buildprotokoll wurde unter "file://c:\Users\******\Documents\Visual Studio 2008\Projects\Listing 8.8\Listing 8.8\Debug\BuildLog.htm" gespeichert.
1>Listing 8.8 - 7 Fehler, 3 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========


Anscheinend hat swprintf.inl ein Problem...?
Der Code der Datei sieht so aus:

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
h>

#if defined(_M_CEE_MIXED)
#pragma managed(push, off)
#endif

#pragma warning( push )
#pragma warning( disable : 4793 4412 )
static __inline int swprintf(wchar_t * _String, size_t _Count, const wchar_t * _Format, ...)
{
    va_list _Arglist;
    int _Ret;
    _crt_va_start(_Arglist, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_at);
    _Ret = _vswprintf_c_l(_String, _Count, _Format _Format, NULL, _Arglist);
    _crt_va_end(_Arglist);
    return _Ret;
}
#pragma warning( pop )

#pragma warning( push )
#pragma warning( disable : 4412 )
static __inline int __CRTDECL vswprintf(wchar_t * _String, size_t _Count, const wchar_t * _Format, va_list _Ap)
{
    return _vswprintf_c_l(_String, _Count, _Format, NULL, _Ap);
}
#pragma warning( pop )
#if defined(_M_CEE_MIXED)
#pragma managed(pop)
#endif

#pragma warning( push )
#pragma warning( disable : 4793 4412 )
static __inline int _swprintf_l(wchar_t * _String, size_t _Count, const wchar_t * _Format, _locale_t _Plocinfo, ...)
{
    va_list _Arglist;
    int _Ret;
    _crt_va_start(_Arglist, _Plocinfo);
    _Ret = _vswprintf_c_l(_String, _Count, _Format, _Plocinfo, _Arglist);
    _crt_va_end(_Arglist);
    return _Ret;
}
#pragma warning( pop )

#pragma warning( push )
#pragma warning( disable : 4412 )
static __inline int __CRTDECL _vswprintf_l(wchar_t * _String, size_t _Count, const wchar_t * _Format, _locale_t _Plocinfo, va_list _Ap)
{
    return _vswprintf_c_l(_String, _Count, _Format, _Plocinfo, _Ap);
}
#pragma warning( pop )

#ifdef __cplusplus
#pragma warning( push )
#pragma warning( disable : 4996 )

#pragma warning( push )
#pragma warning( disable : 4793 4141 )
extern "C++" _SWPRINTFS_DEPRECATED _CRT_INSECURE_DEPRECATE(swprintf_s) __inline int swprintf(_Pre_notnull_ _Post_z_ wchar_t * _String, _In_z_ _Printf_format_string_ const wchar_t * _Format, ...)
{
    va_list _Arglist;
    _crt_va_start(_Arglist, _Format);
    int _Ret = _vswprintf(_String, _Format, _Arglist);
    _crt_va_end(_Arglist);
    return _Ret;
}
#pragma warning( pop )

#pragma warning( push )
#pragma warning( disable : 4141 )
extern "C++" _SWPRINTFS_DEPRECATED _CRT_INSECURE_DEPRECATE(vswprintf_s) __inline int __CRTDECL vswprintf(_Pre_notnull_ _Post_z_ wchar_t * _String, _In_z_ _Printf_format_string_ const wchar_t * _Format, va_list _Ap)
{
    return _vswprintf(_String, _Format, _Ap);
}
#pragma warning( pop )

#pragma warning( pop )

#endif  /* __cplusplus */

#endif /* RC_INVOKED */
#endif /* _INC_SWPRINTF_INL_ */


Ist die Datei kaputt oder so?
Ich hab das Visual Studio erst letztens installiert und bisher auch nix dran geändert.
Bin dezent Ratlos ^^

MfG,
Rabbit

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

2

05.09.2009, 15:35

Also ich weis net wo das "h> " in der ersten Zeile herkommt aber C++ is das auf jeden Fall nicht ;)
Mach das mal weg und schau obs dann geht...

3

05.09.2009, 15:51

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(12) : warning C4002: Zu viele übergebene Parameter für das Makro '_crt_va_start'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(12) : error C2065: '_CEE_t': nichtdeklarierter Bezeichner
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(12) : error C2065: '_CEE_t': nichtdeklarierter Bezeichner
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(12) : error C2070: ''unknown-type'': Ungültiger sizeof-Operand
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(13) : error C2146: Syntaxfehler: Fehlendes ')' vor Bezeichner '_Format'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(13) : error C2660: '_vswprintf_c_l': Funktion akzeptiert keine 3 Argumente
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(13) : error C2059: Syntaxfehler: ')'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(75) : warning C4068: Unbekanntes Pragma
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(75) : error C2018: Unbekanntes Zeichen '0x8'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(75) : error C2018: Unbekanntes Zeichen '0x60'
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl(103) : fatal error C1070: Fehlende Zuordnung von #if und #endif in Datei "c:\program files (x86)\microsoft visual studio 9.0\vc\include\swprintf.inl"
1>Das Buildprotokoll wurde unter "file://c:\Users\******\Documents\Visual Studio 2008\Projects\lool\lool\Debug\BuildLog.htm" gespeichert.
1>lool - 9 Fehler, 2 Warnung(en)
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========


Nachdem ich total umständlich die Datei auf den Desktop ziehen musste, dort ändern und dann wieder zurück in das Originalverzeichniss legen musste, weil VC++ sich geweigert hat, die Datei einfach so zu speichern, kam jetzt die Fehlermeldung.

Wie kann das denn sein, dass der ne Datei installiert, die er nicht mal kompilieren kann? :shock:

dot

Supermoderator

Beiträge: 9 757

Wohnort: Graz

  • Private Nachricht senden

4

05.09.2009, 16:23

Also für mich schaut das stark danach aus als wäre da was an deiner Visual Studio Installation kaputtgegangen...

Das sieht auf jeden Fall falsch aus, ebenfalls keine Ahnung wo das herkommt:

C-/C++-Quelltext

1
    _crt_va_start(_Arglist, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_t, _CEE_at); 


versuchs stattdessen mal mit

C-/C++-Quelltext

1
    _crt_va_start(_Arglist, _Format); 


Wenn das auch nix hilft wirds wohl am einfachsten sein wenn du Visual Studio deinstallierst und neu installierst...

5

05.09.2009, 17:18

Reparieren/Neuinstallieren = fail.

Manuell neu installieren = success :D

Geht alles.
Jetzt muss ich nurnoch rausfinden, warum Vista hin und wieder mal 30sek Pause macht, aber das gehört hier nicht hin...

Ich mag microsoft nicht :evil:

K-Bal

Alter Hase

Beiträge: 703

Wohnort: Aachen

Beruf: Student (Elektrotechnik, Technische Informatik)

  • Private Nachricht senden

6

05.09.2009, 19:07

Zitat von »"Jack_Rabbit"«


Ich mag microsoft nicht :evil:


Gibt ja zum Glück genügend Alternativen ;)

goldfisch007

Alter Hase

Beiträge: 446

Wohnort: Süden von Berlin

  • Private Nachricht senden

7

05.09.2009, 23:22

ich muss das gerade verwenden und alle sind volll
closed source drauf...
Wir bauen auf und reißen nieder, so ham wir Arbeit ima wieder...
--------------------
http://www.piratenpartei.de/tmp/images/Slogans_5_0.png
--------------------
Sei stets geduldig gegenüber Leuten, die nicht mit dir übereinstimmen. Sie haben ein Recht auf ihren Standpunkt - trotz ihrer lächerlichen Meinung. (F. Hollaender, geklaut von Helmut xD)

Lerikson

Alter Hase

Beiträge: 412

Wohnort: nördlich von Hamburg

Beruf: Schüler

  • Private Nachricht senden

8

06.09.2009, 20:23

Zitat

Zitat

Ich mag microsoft nicht Evil or Very Mad



Gibt ja zum Glück genügend Alternativen Wink


z.B. Ubuntu! ;D
Aber das lässt es sich nicht so toll mit Visual Studio arbeiten, dafür muss man dann W.I.N.E. (Wine Is Not An Emulator) welcher ein Emulator für Windows Programme ist installieren, da hilfts glaubich mehr sich mit Vista zu bekriegen (kenn ich aus eigener Erfahrung ;-)), obwohl ich Ubuntu sonst nur empfehlen kann, aber ich bin jetz mal lieber wieder still....

goldfisch007

Alter Hase

Beiträge: 446

Wohnort: Süden von Berlin

  • Private Nachricht senden

9

06.09.2009, 22:15

ich mag VC 2008 (net...) da hilft wine auch nur net...
Wir bauen auf und reißen nieder, so ham wir Arbeit ima wieder...
--------------------
http://www.piratenpartei.de/tmp/images/Slogans_5_0.png
--------------------
Sei stets geduldig gegenüber Leuten, die nicht mit dir übereinstimmen. Sie haben ein Recht auf ihren Standpunkt - trotz ihrer lächerlichen Meinung. (F. Hollaender, geklaut von Helmut xD)

Werbeanzeige