<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>suu-g</author_name>
  <author_url>https://blog.hatena.ne.jp/suu-g/</author_url>
  <blog_title>suu-g's diary</blog_title>
  <blog_url>https://suu-g.hateblo.jp/</blog_url>
  <categories>
    <anon>C/C++</anon>
    <anon>gcc</anon>
  </categories>
  <description>gcc拡張を使うとmain関数の前に色々出来ると聞いたので、遊んでみた。 結論からいうと、二通りのやりかたがありそうで、私の環境*1ではどちらも問題無く動作した。 __attribute__((constructor)) という指定 関数の宣言に際して、__attribute__で関数にconstructor属性を付け加える。constructor属性がある関数はmain関数よりも先で呼び出されるんだってさ。 ほんとかねえ？ 実験してみる。 main関数が呼び出されたらエラーを出力するので、すぐ分かります。 #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #ifd…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsuu-g.hateblo.jp%2Fentry%2F20080307%2F1204906279&quot; title=&quot;gcc拡張を使って、main関数より前にFizzBuzzを実行させてみた - suu-g&amp;#39;s diary&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2008-03-07 01:11:19</published>
  <title>gcc拡張を使って、main関数より前にFizzBuzzを実行させてみた</title>
  <type>rich</type>
  <url>https://suu-g.hateblo.jp/entry/20080307/1204906279</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
