<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[_ctime64 und _ctime64_s]]></title><description><![CDATA[<p>Hallo zusammen.</p>
<p>Verwende momentan eine Klasse in der die Funktion _ctime64 aufgerufen wird. Nun erhalte ich die Warnung:</p>
<pre><code>'_ctime64': This function or variable may be unsafe. Consider using _ctime64_s instead.
</code></pre>
<p>Die Funktion _ctime64 wird momentan wie folgt aufgerufen:</p>
<pre><code class="language-cpp">char* timeline;
struct __timeb64 timebuffer;
timeline=_ctime64(&amp;(timebuffer.time));
</code></pre>
<p>_ctime64_s benötigt nun allerdings einen weiteren Parameter. -&gt; char(&amp;_Buffer)[_Size]</p>
<p>hier weiß ich überhaupt nicht was übergeben. Kann mir da jemand helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/302997/_ctime64-und-_ctime64_s</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 00:01:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/302997.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 May 2012 08:33:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to _ctime64 und _ctime64_s on Thu, 03 May 2012 08:33:35 GMT]]></title><description><![CDATA[<p>Hallo zusammen.</p>
<p>Verwende momentan eine Klasse in der die Funktion _ctime64 aufgerufen wird. Nun erhalte ich die Warnung:</p>
<pre><code>'_ctime64': This function or variable may be unsafe. Consider using _ctime64_s instead.
</code></pre>
<p>Die Funktion _ctime64 wird momentan wie folgt aufgerufen:</p>
<pre><code class="language-cpp">char* timeline;
struct __timeb64 timebuffer;
timeline=_ctime64(&amp;(timebuffer.time));
</code></pre>
<p>_ctime64_s benötigt nun allerdings einen weiteren Parameter. -&gt; char(&amp;_Buffer)[_Size]</p>
<p>hier weiß ich überhaupt nicht was übergeben. Kann mir da jemand helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207833</guid><dc:creator><![CDATA[y-vonne]]></dc:creator><pubDate>Thu, 03 May 2012 08:33:35 GMT</pubDate></item><item><title><![CDATA[Reply to _ctime64 und _ctime64_s on Thu, 03 May 2012 08:43:36 GMT]]></title><description><![CDATA[<p>_ctime64 ist nicht reentrant. _ctime64_s ist Microsofts Methode, das zu umschiffen. Gedacht ist das als</p>
<pre><code class="language-cpp">char timeline[26];

if(0 == _ctime64_s(timeline, 26, &amp;timebuffer.time)) {
  /* Erfolg */
} else {
  /* Fehler */
}
</code></pre>
<p>Die 26 ist in der <a href="http://msdn.microsoft.com/de-de/library/4ey61ayt%28v=vs.80%29.aspx" rel="nofollow">Dokumentation</a> als ausreichende Bufferlänge angegeben. Längere Buffer schaden natürlich nichts, wären aber verschwenderisch.</p>
<p>Ansonsten gehört der Thread eigentlich ins WinAPI-Forum. Das POSIX-Gegenstück zu dieser Funktion heißt _ctime_r.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207835</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 03 May 2012 08:43:36 GMT</pubDate></item><item><title><![CDATA[Reply to _ctime64 und _ctime64_s on Thu, 03 May 2012 08:44:23 GMT]]></title><description><![CDATA[<p>Entschuldigung. Das POSIX-Gegenstück heißt ctime_r (ohne Unterstrich am Anfang).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207836</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 03 May 2012 08:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to _ctime64 und _ctime64_s on Thu, 03 May 2012 08:59:33 GMT]]></title><description><![CDATA[<p>Dank dir mal.</p>
<p>Das wäre dann die Überladung. Wie sieht es mit dem Aufruf in der ersten Version aus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207844</guid><dc:creator><![CDATA[y-vonne]]></dc:creator><pubDate>Thu, 03 May 2012 08:59:33 GMT</pubDate></item><item><title><![CDATA[Reply to _ctime64 und _ctime64_s on Thu, 03 May 2012 09:21:38 GMT]]></title><description><![CDATA[<p>Ah, das hatte ich gar nicht gesehen. Der Aufruf müsste so gehen:</p>
<pre><code class="language-cpp">char timeline[26];

if(0 == _ctime64_s(timeline, &amp;timebuffer.time)) {
  /* Erfolg */
} else {
  /* Fehler */
}
</code></pre>
<p>Die Funktionsvorlage wird wohl etwa so aussehen:</p>
<pre><code class="language-cpp">template &lt;size_t size&gt;
errno_t _ctime64_s( 
   char (&amp;buffer)[size],
   const __time64_t *time
) {
  return _ctime64_s(buffer, size, time);
}
</code></pre>
<p>Der Unterschied zur anderen Variante ist, dass der Compiler die Länge des übergebenen Buffers selbst feststellt. Das funktioniert natürlich nur, wenn er das kann, also mit Arrays wie oben gezeigt. Wenn du da einen Zeiger reinzustopfen versuchst, geht das schief, weil sich dieser nicht an char(&amp;)[size] binden lässt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2207849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2207849</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 03 May 2012 09:21:38 GMT</pubDate></item></channel></rss>