<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Austin&#039;s Note</title>
	<atom:link href="http://blog.gclin.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gclin.org</link>
	<description>全新的正體中文 WordPress 網誌！</description>
	<lastBuildDate>Fri, 22 Jul 2011 05:39:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://blog.gclin.org/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>Shell script輸出有顏色的文字</title>
		<link>http://blog.gclin.org/2011/07/shell-script-colored-text/</link>
		<comments>http://blog.gclin.org/2011/07/shell-script-colored-text/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 05:39:50 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[Colored]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[tput]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=982</guid>
		<description><![CDATA[# Color defination txtRed=$(tput setaf 1) txtGreen=$(tput setaf 2) txtYellow=$(tput setaf 3) txtBlue=$(tput setaf 4) txtPurple=$(tput setaf 5) txtCyan=$(tput setaf 6) txtWhite=$(tput setaf 7) txtReset=$(tput sgr0) # Style defination txtBold=$(tput bold) txtUL=$(tput smul) # Example echo &#34;${txtRed}Red text&#34; echo &#34;still Red text&#34; echo &#34;$txtReset&#34; echo &#34;Normal text&#34; Reference: How to echo colored text in linux [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash; title: ;">
# Color defination
txtRed=$(tput setaf 1)
txtGreen=$(tput setaf 2)
txtYellow=$(tput setaf 3)
txtBlue=$(tput setaf 4)
txtPurple=$(tput setaf 5)
txtCyan=$(tput setaf 6)
txtWhite=$(tput setaf 7)
txtReset=$(tput sgr0)

# Style defination
txtBold=$(tput bold)
txtUL=$(tput smul)

# Example
echo &quot;${txtRed}Red text&quot;
echo &quot;still Red text&quot;

echo &quot;$txtReset&quot;
echo &quot;Normal text&quot;
</pre>
<p>Reference: <a target="_blank" href="http://kedar.nitty-witty.com/blog/how-to-echo-colored-text-in-shell-script">How to echo colored text in linux shell script</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/07/shell-script-colored-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse RAP execute javascript</title>
		<link>http://blog.gclin.org/2011/07/eclipse-rap-execute-javascript/</link>
		<comments>http://blog.gclin.org/2011/07/eclipse-rap-execute-javascript/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 01:50:49 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[PhaseListener]]></category>
		<category><![CDATA[RAP]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=980</guid>
		<description><![CDATA[方法一把輸出字串當javascript執行，方法二只是把方法一包到PhaseListener，為什麼要這樣包還不太清楚，所以先用方法一 try { RWT.getResponse().getWriter().println(&#34;alert('123');&#34;); } catch (IOException ex) { ex.printStackTrace(); } RWT.getLifeCycle().addPhaseListener(new PhaseListener() { private static final long serialVersionUID = 1995219943700635190L; @Override public PhaseId getPhaseId() { return PhaseId.RENDER; } @Override public void beforePhase(PhaseEvent event) { try { RWT.getResponse().getWriter().println(&#34;alert('1');&#34;); } catch (IOException e) { e.printStackTrace(); } } @Override public void afterPhase(PhaseEvent event) { try { RWT.getResponse().getWriter().println(&#34;alert('2');&#34;); [...]]]></description>
			<content:encoded><![CDATA[<p>方法一把輸出字串當javascript執行，方法二只是把方法一包到PhaseListener，為什麼要這樣包還不太清楚，所以先用方法一</p>
<pre class="brush: java; title: 方法一;">
try {
	RWT.getResponse().getWriter().println(&quot;alert('123');&quot;);
} catch (IOException ex) {
	ex.printStackTrace();
}
</pre>
<pre class="brush: java; title: 方法二;">
RWT.getLifeCycle().addPhaseListener(new PhaseListener() {
	private static final long serialVersionUID = 1995219943700635190L;

	@Override
	public PhaseId getPhaseId() {
		return PhaseId.RENDER;
	}

	@Override
	public void beforePhase(PhaseEvent event) {
		try {
			RWT.getResponse().getWriter().println(&quot;alert('1');&quot;);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void afterPhase(PhaseEvent event) {
		try {
			RWT.getResponse().getWriter().println(&quot;alert('2');&quot;);
		} catch (IOException e) {
			e.printStackTrace();
		}
		RWT.getLifeCycle().removePhaseListener(this);
	}
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/07/eclipse-rap-execute-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HttpBaseJsp</title>
		<link>http://blog.gclin.org/2011/05/httpbasejsp/</link>
		<comments>http://blog.gclin.org/2011/05/httpbasejsp/#comments</comments>
		<pubDate>Wed, 18 May 2011 05:55:10 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=972</guid>
		<description><![CDATA[package org.gclin.core.web; import java.io.IOException; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.HttpJspPage; import javax.servlet.http.HttpServlet; public abstract class HttpBaseJsp extends HttpServlet implements HttpJspPage { private static final long serialVersionUID = 5971944450223631606L; @Override public void init(ServletConfig config) throws ServletException { super.init(config); jspInit(); _jspInit(); } @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: java; title: HttpBaseJsp.java;">
package org.gclin.core.web;

import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.HttpJspPage;
import javax.servlet.http.HttpServlet;

public abstract class HttpBaseJsp extends HttpServlet implements HttpJspPage {
	private static final long serialVersionUID = 5971944450223631606L;

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		jspInit();
		_jspInit();
	}

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		_jspService(request, response);
	}

	@Override
	public void destroy() {
		jspDestroy();
		_jspDestroy();
	}

	@Override
	public void jspInit() {}
	public void _jspInit() {}

	@Override
	public void jspDestroy() {}
	protected void _jspDestroy() {}

	@Override
	public void _jspService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}

}
</pre>
<pre class="brush: java; title: xxxx.jsp;">
&lt;%@page contentType=&quot;text/html; charset=BIG5&quot;
	extends=&quot;org.gclin.core.web.HttpBaseJsp&quot;%&gt;
...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/05/httpbasejsp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Develop Google App Engine by Eclipse</title>
		<link>http://blog.gclin.org/2011/04/develop-google-app-engine-by-eclipse/</link>
		<comments>http://blog.gclin.org/2011/04/develop-google-app-engine-by-eclipse/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 09:00:59 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GAE]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=918</guid>
		<description><![CDATA[Step 1. Install plugin from update site Eclipse =&#62; Help =&#62; Install New Software =&#62; Add Name: Google app Engine Location: http://dl.google.com/eclipse/plugin/3.6 Step 2. Create GAE project File =&#62; New =&#62; Project type filter text: Web Application Project type project name, package and uncheck "Use Google Toolkit" Step 3. Specified applications for this project Package [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Step 1. Install plugin from update site</strong><br />
Eclipse =&gt; Help =&gt; Install New Software =&gt; Add<br />
Name: Google app Engine<br />
Location: http://dl.google.com/eclipse/plugin/3.6</p>
<p><strong>Step 2. Create GAE project</strong><br />
File =&gt; New =&gt; Project<br />
type filter text: Web Application Project<br />
type project name, package and uncheck "Use Google Toolkit"</p>
<p><strong>Step 3. Specified applications for this project</strong><br />
Package Explorer =&gt; this project =&gt; war =&gt; WEB-INF =&gt; appengine-web.xml<br />
&lt;application&gt;<em><strong>name of your application</strong></em>&lt;/application&gt;</p>
<p><strong>Step 4. Test and Deploy</strong><br />
Just click the button "Run" or "Deploy App engine project" on toolbar<br />
Test URL: http://localhost:8888/ (Default)<br />
GAE URL: http://<em><strong>name of your application</strong></em>.appspot.com</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/04/develop-google-app-engine-by-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAP Login Dialog</title>
		<link>http://blog.gclin.org/2011/04/rap-login-dialog/</link>
		<comments>http://blog.gclin.org/2011/04/rap-login-dialog/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 06:17:43 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RAP]]></category>
		<category><![CDATA[Dialog]]></category>
		<category><![CDATA[EntryPoint]]></category>
		<category><![CDATA[Login]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=912</guid>
		<description><![CDATA[public class MyEntryPoint implements IEntryPoint { public int createUI() { Display display = PlatformUI.createDisplay(); LoginInfo info = null; while (info == null) { LogonDialog dialog = new LogonDialog(display.getActiveShell()); try { info = checkLogin(dialog.getUsername(), dialog.getPassword()); } catch (Exception e) { MessageDialog.openError(display.getActiveShell(), &#34;Error&#34;, &#34;Logon Fail:\n&#34; + e.getMessage()); } } return PlatformUI.createAndRunWorkbench( display, new ApplicationWorkbenchAdvisor()); } }]]></description>
			<content:encoded><![CDATA[<pre class="brush: java; title: ;">
public class MyEntryPoint implements IEntryPoint {
    public int createUI() {
        Display display = PlatformUI.createDisplay();
        LoginInfo info = null;
        while (info == null) {
            LogonDialog dialog = new LogonDialog(display.getActiveShell());
            try {
                info = checkLogin(dialog.getUsername(), dialog.getPassword());
            } catch (Exception e) {
                MessageDialog.openError(display.getActiveShell(), &quot;Error&quot;, &quot;Logon Fail:\n&quot; + e.getMessage());
            }
        }
        return PlatformUI.createAndRunWorkbench( display, new ApplicationWorkbenchAdvisor());
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/04/rap-login-dialog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse for RCP and RAP + GWT + WindowBuilder</title>
		<link>http://blog.gclin.org/2011/02/eclipse-for-rcp-and-rap-gwt-windowbuilder/</link>
		<comments>http://blog.gclin.org/2011/02/eclipse-for-rcp-and-rap-gwt-windowbuilder/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 15:49:38 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RAP]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[RCP]]></category>
		<category><![CDATA[SWT]]></category>
		<category><![CDATA[WindowBuilder]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=908</guid>
		<description><![CDATA[Eclipse for RCP and RAP Developers http://www.eclipse.org/downloads/packages/eclipse-rcp-and-rap-developers/heliossr1 Google Web Toolkit Overview http://code.google.com/intl/en/webtoolkit/overview.html WindowBuilder Pro http://code.google.com/intl/zh-TW/javadevtools/wbpro/index.html]]></description>
			<content:encoded><![CDATA[<p>Eclipse for RCP and RAP Developers<br />
<a target="_blank" href="http://www.eclipse.org/downloads/packages/eclipse-rcp-and-rap-developers/heliossr1">http://www.eclipse.org/downloads/packages/eclipse-rcp-and-rap-developers/heliossr1</a></p>
<p>Google Web Toolkit Overview<br />
<a target="_blank" href="http://code.google.com/intl/en/webtoolkit/overview.html">http://code.google.com/intl/en/webtoolkit/overview.html</a></p>
<p>WindowBuilder Pro<br />
<a target="_blank" href="http://code.google.com/intl/zh-TW/javadevtools/wbpro/index.html">http://code.google.com/intl/zh-TW/javadevtools/wbpro/index.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2011/02/eclipse-for-rcp-and-rap-gwt-windowbuilder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerPoint中雙螢幕設定</title>
		<link>http://blog.gclin.org/2010/12/powerpoint-dual-screen/</link>
		<comments>http://blog.gclin.org/2010/12/powerpoint-dual-screen/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 09:46:50 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[Dual Screen]]></category>
		<category><![CDATA[PowerPoint]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=897</guid>
		<description><![CDATA[點擊選單 投影片放映 => 設定放映放式 1. 指定播放畫面 2. 顯示簡報者檢視畫面(感覺不錯)]]></description>
			<content:encoded><![CDATA[<p>點擊選單 <strong>投影片放映</strong> => <strong>設定放映放式</strong><br />
1. 指定播放畫面<br />
2. 顯示簡報者檢視畫面(感覺不錯)</p>
<p><a href="http://blog.gclin.org/wp-content/uploads/2010/12/powerpoint-dual-screen1.jpg"><img src="http://blog.gclin.org/wp-content/uploads/2010/12/powerpoint-dual-screen1.jpg" alt="" title="powerpoint-dual-screen1" width="468" height="389" class="size-full wp-image-898" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2010/12/powerpoint-dual-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cygwin快速複製貼上</title>
		<link>http://blog.gclin.org/2010/12/cygwin-copy-paste/</link>
		<comments>http://blog.gclin.org/2010/12/cygwin-copy-paste/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 02:13:59 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[Cygwin]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=890</guid>
		<description><![CDATA[Step 1. 啟動Cygwin Step 2. 開啟視窗內容 標題列按右鍵 => 內容 Step 3. 勾選快速編輯模式 選項 => 快速編輯模式 => 確定]]></description>
			<content:encoded><![CDATA[<p><strong>Step 1. 啟動Cygwin</strong></p>
<p><strong>Step 2. 開啟視窗內容</strong><br />
標題列按右鍵 => 內容</p>
<p><strong>Step 3. 勾選快速編輯模式</strong><br />
選項 => 快速編輯模式 => 確定</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2010/12/cygwin-copy-paste/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Boost libraries with Visual Studio 2008</title>
		<link>http://blog.gclin.org/2010/04/boost-libraries-visual-studio/</link>
		<comments>http://blog.gclin.org/2010/04/boost-libraries-visual-studio/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 12:07:02 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=881</guid>
		<description><![CDATA[網站：Boost C++ Libraries(下載) Step 1. 取得Boost libraries 到網站的Download去下載，然後解壓縮(D:/boost_1_42_0) Step 2. 建置Bjam 進入D:/boost_1_42_0，然後執行bootstrap.bat 跑完之後在這個目錄就會多出一個bjam.exe Step 3. 建置Boost Libraries 在D:/boost_1_42_0建立一個buildall_vc90.bat內容如下 bjam toolset=msvc-9.0 variant=debug threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION bjam toolset=msvc-9.0 variant=release threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION 執行剛剛建立的那個buildall_vc90.bat，等他跑完在D:\boost_1_42_0\stage\lib應該有一堆*.lib、*.dll Step 4. 設定Visual Studio 2008 開啟Visual Studio 2008，工具 => 選項 => 專案和方案 => VC++目錄 顯示目錄的那個下拉選單 選Include檔案加入D:\boost_1_42_0 選程式庫檔加入D:\boost_1_42_0\stage\lib]]></description>
			<content:encoded><![CDATA[<p>網站：<a href="http://www.boost.org/" target="_blank">Boost C++ Libraries</a>(<a href="http://www.boost.org/users/download/" target="_blank">下載</a>)</p>
<p><strong>Step 1. 取得Boost libraries</strong><br />
到網站的Download去下載，然後解壓縮(D:/boost_1_42_0)</p>
<p><strong>Step 2. 建置Bjam</strong><br />
進入D:/boost_1_42_0，然後執行bootstrap.bat<br />
跑完之後在這個目錄就會多出一個bjam.exe</p>
<p><strong>Step 3. 建置Boost Libraries</strong><br />
在D:/boost_1_42_0建立一個buildall_vc90.bat內容如下</p>
<pre class="brush: powershell; title: buildall_vc90.bat;">
bjam toolset=msvc-9.0 variant=debug threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION
bjam toolset=msvc-9.0 variant=release threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION
</pre>
<p>執行剛剛建立的那個buildall_vc90.bat，等他跑完在D:\boost_1_42_0\stage\lib應該有一堆*.lib、*.dll</p>
<p><strong>Step 4. 設定Visual Studio 2008</strong><br />
開啟Visual Studio 2008，工具 => 選項 => 專案和方案 => VC++目錄<br />
顯示目錄的那個下拉選單<br />
選<strong>Include檔案</strong>加入<strong>D:\boost_1_42_0</strong><br />
選<strong>程式庫檔</strong>加入<strong>D:\boost_1_42_0\stage\lib</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2010/04/boost-libraries-visual-studio/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Stack overflow</title>
		<link>http://blog.gclin.org/2010/03/stack-overflow/</link>
		<comments>http://blog.gclin.org/2010/03/stack-overflow/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 17:19:21 +0000</pubDate>
		<dc:creator>Austin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[未分類]]></category>
		<category><![CDATA[Heap]]></category>
		<category><![CDATA[Stack]]></category>
		<category><![CDATA[Stack overflow]]></category>

		<guid isPermaLink="false">http://blog.gclin.org/?p=849</guid>
		<description><![CDATA[最近遇到的一個問題Stack overflow，不難解~改用new＆delete就對了丫，結果還是錯，找了一下資料是用new＆delete沒錯，但是為啥不行，最後發現原來還有別的地方有用一樣的數字來宣告，程式如下： 一開始找出來發生錯誤的地方(我一直以為是這錯@@a) const unsigned int numSolution1 = 50; // 掛 Solution sol1[numSolution1]; // 正常來說改成這樣就OK了，結果調成100還是會掛 Solution *sol1 = new Solution[numSolution1]; 最後發現~另外還有幾個個檔案有類似下面的程式： // 掛，因為這邊也要改用new const unsigned int numSolution2 = numSolution1 * 2; Solution sol2[numSolution2]; 　 Stack overflow Compile時會過，執行時會錯@@ 錯誤訊息：. . . . . . 發生未處理的例外狀況: 0xC00000FD: Stack overflow 主要原因是因為Stack有大小限制，而且我們一般直接宣告出來的變數是放在Stack，如果在Stack放出大量資料，就會發生Stack overflow，解決方法就是改用new＆delete，這樣一來資料就會改成用heap來儲存，也就不會受限於Stack的大小了。只是速度也比較慢，另外要特別注意記得要delete。 // 下面四個for的cup time都介於0.25s左右 for(unsigned int i [...]]]></description>
			<content:encoded><![CDATA[<p>最近遇到的一個問題Stack overflow，不難解~改用new＆delete就對了丫，結果還是錯，找了一下資料是用new＆delete沒錯，但是為啥不行，最後發現原來還有別的地方有用一樣的數字來宣告，程式如下：<br />
一開始找出來發生錯誤的地方(我一直以為是這錯@@a)</p>
<pre class="brush: cpp; title: ;">
const unsigned int numSolution1 = 50;

// 掛
Solution sol1[numSolution1];

// 正常來說改成這樣就OK了，結果調成100還是會掛
Solution *sol1 = new Solution[numSolution1];
</pre>
<p>最後發現~另外還有幾個個檔案有類似下面的程式：</p>
<pre class="brush: cpp; title: ;">
// 掛，因為這邊也要改用new
const unsigned int numSolution2 = numSolution1 * 2;
Solution sol2[numSolution2];
</pre>
<p><span id="more-849"></span>　<br />
<strong>Stack overflow</strong><br />
Compile時會過，執行時會錯@@<br />
錯誤訊息：. . . . . . 發生未處理的例外狀況: 0xC00000FD: Stack overflow<br />
主要原因是因為Stack有大小限制，而且我們一般直接宣告出來的變數是放在Stack，如果在Stack放出大量資料，就會發生Stack overflow，解決方法就是改用new＆delete，這樣一來資料就會改成用heap來儲存，也就不會受限於Stack的大小了。只是速度也比較慢，另外要特別注意記得要delete。</p>
<pre class="brush: cpp; title: ;">
// 下面四個for的cup time都介於0.25s左右
for(unsigned int i = 0; i &lt; 100000000; ++i) {
	int sol[20];
}

for(unsigned int i = 0; i &lt; 250000; ++i) {
	int *sol = new int[20];
	delete [] sol;
}

for(unsigned int i = 0; i &lt; 100000000; ++i) {
	Solution sol[20];
}

for(unsigned int i = 0; i &lt; 2500; ++i) {
	Solution *sol = new Solution[20];
	delete [] sol;
}
</pre>
<p>　<br />
參考資料：<a target="_blank" href="http://godman362.blogspot.com/2008/08/heapstack.html">堆(heap)和棧(stack)</a>、<a target="_blank" href="http://www.wretch.cc/blog/ahongyeh/28870839">MFC &#8211; STACK溢位</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gclin.org/2010/03/stack-overflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

