Forum: Mikrocontroller und Digitale Elektronik Batch file IAR


von Michael U (Gast)


Lesenswert?

Hallo,

ich möchte automatisch beim kompilieren die derzeitige Uhrzeit in ein 
Headerfile speichern. Ich benutze die IAR embedded workbench und 
programmiere einen controller in C.
Meine Idee ist folgende:
Ich möchte ein BATCH file schreiben, dass mir die derzeitige Uhrzeit des 
Betriebssystems ausliest. Das Batchfile schreibt die Uhrzeit dann in das 
Headerfile welches sie erstellt wenn es nicht vorhanden ist. Wenn es 
vorhanden ist, wird es einfach überschrieben.
Das BATCH file soll aufgerufen werden, wenn man den MAKE knopf in der 
IAR workbench drückt. Zuerst soll dann also das batch file aufgerufen 
werden und dann sollen die c-files kompiliert werden.

Kann mir jemand helfen ein Batch file in die IAR workbench aufzunehmen, 
so dass das Batchfile an der richtigen Stelle aufgerufen wird?

Ich bin auch für weitere Ideen offen. Mein Ziel ist es lediglich die 
Uhrzeit von Windows in eine C-Header zu kopieren.

Ich freue mich auf eure Antworten.

von Martin T. (mthomas) (Moderator) Benutzerseite


Lesenswert?

Mglw. ist ein Ansatz mittels _TIME_ einfacher.

von Michael U (Gast)


Lesenswert?

Hi

wie meinst du das mit TIME ? Kannst du das vielleicht etwas genauer 
ausführen?

Gruß Micha

von ... (Gast)


Lesenswert?

Gemeint ist das vordefinierte Makro __TIME__ (jeweils 2 Unterstricche 
vorn und hinten). Ist Teil des C-Standards und sollte in jedem 
anständigen C-Buch beschrieben sein.

From ANSI/ISO 9899-1990, American National Standard for Programming 
Languages - C

----

6.8.8 Predefined macro names

The following names shall be defined by the implementation:

__LINE__ The line number of the current source line (a decimal 
constant).

__FILE__ The presumed name of the source file (a character string 
literal).

__DATE__ The date of translation of the source file (a character 
string literal of the form "Mmm dd yyyy", where the names of the months 
are the same as those generated by the asctime function, and the first 
character of dd is a space character if the value is less than 10). If 
the date of translation is not available, an implementation-defined 
valid date shall be supplied.

__TIME__ The time of translation of the source file (a character 
string literal of the form "hh:mm:ss" as in the time generated by the 
asctime function). If the time of translation is not available, an 
implementation-defined valid time shall be supplied.

__STDC__ The decimal constant 1, intended to indicate a conforming 
implementation.

The values of the predefined macros (except for __LINE__ and 
__FILE__) remain constant throughout the translation unit.

None of these macro names, nor the identifier defined, shall be the 
subject of a #define or a #undef preprocessing directive. All predefined 
macro names shall begin with a leading underscore followed by an 
uppercase letter or a second underscore.

----

Annex G (informative) Portability Issues

G.2 Undefined behavior

-- One of the following identifiers is the subject of a #define or 
#undef preprocessing directive: defined, __LINE__, __FILE__, 
__DATE__, __TIME__, or __STDC__ (6.8.8).

G.3 Implementation-defined behavior

G.3.13 Preprocessing directives

-- The definitions for __DATE__ and __TIME__ when respectively, the 
date and time of translation are not available (6.8.8).

----

von Michael U (Gast)


Lesenswert?

Danke für die Antwort. Das war genau das was ich gesucht hatte.

Gruß Michael

von Michael (Gast)


Lesenswert?

Gibt es vielleicht dennoch die Möglichkeit ein Batchfile zu schreiben 
und dieses dann beim kompilieren in der IAR auszuführen?

Gruß Micha

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.