<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>simotin13</author_name>
  <author_url>https://blog.hatena.ne.jp/simotin13/</author_url>
  <blog_title>simotin13's message</blog_title>
  <blog_url>https://mcommit.hatenadiary.com/</blog_url>
  <categories>
    <anon>C言語</anon>
  </categories>
  <description>「試験をしているんだけど、実行中に関数の戻り値を変える方法はないかな？」 と相談を受けました。C言語で単体テストをする場合、システムコールやライブラリ関数はダミーの関数を用意しておいて自作部分の実装をテストすることはよくありますが、実行中にこのダミー関数の振舞いを変えたいという趣旨です。*1単純にダミー関数の戻り値をグローバル変数にしてしまえば問題はありません。 ただしテストコードが多いと呼び出し元のテストコードが少し複雑になりそうです。少し考えてみましたが、 DLL,共有ライブラリならできるのでは？ というのが私の思いついた答えでした。linuxだとdlopen,dlsym,dlcloseを…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmcommit.hatenadiary.com%2Fentry%2F2019%2F01%2F20%2F124639&quot; title=&quot;C言語の関数の戻り値を実行時に変更する - simotin13&amp;#39;s message&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>https://images-fe.ssl-images-amazon.com/images/I/51yVHZxEmuL._SL160_.jpg</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2019-01-20 12:46:39</published>
  <title>C言語の関数の戻り値を実行時に変更する</title>
  <type>rich</type>
  <url>https://mcommit.hatenadiary.com/entry/2019/01/20/124639</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
