Showing posts with label tricks. Show all posts
Showing posts with label tricks. Show all posts
Thursday, July 13, 2017
C/C++中避免unused variable造成報錯的方法(void cast of argc/argv)
一些Signal handler或是Thread(CMSIS-RTOS)的建立會要求你的的函數強制吃一些argument。
當你的compiler開 -Werror -Wall -Wunused-variable選項時,這些未被使用的變數會報錯。
這時有兩個解法。
1.void cast
例如:
void f(void * argc)
{
(void) argc;
}
這會無害的去用到這個變數。
2.自己等於自己
例如:
void f(void * argc)
{
argc = argc;
}
這兩招就是欺騙compiler這些變數已經被使用。
我第一次看到這寫法真的嚇到了。
以下是stackoverflow的討論。
https://stackoverflow.com/questions/21045615/what-does-voidvar-actually-do
https://stackoverflow.com/questions/8052091/void-cast-of-argc-and-argv?rq=1
Friday, March 3, 2017
[Note] GDB 一些指令功能速查
[Note] GDB 一些指令功能速查
前情提要
這篇主要是介紹gdb的一些常用功能,遇到的時候方便google。
常用功能
- backtrace
- breakpoint
- watchpoint
- stopwatch
- dump register
- dump variable
- continue and stop
- disasmmebly
- return
指令速查
- backtrace
- bt
- breakpoint
- b
- br
- watchpoint
- watch variable_name or watch variable_address
- stopwatch
- maint link
- dump register
- info r
- dump variable
- print variable_name
- print &variable_name => get address
- print *variable_address => get address contents
- info display
- continue and stop
- c => continue
- r= > run
- stop => Ctrl+c
- disasmmebly
- disassemble (func…) link
- layout asm
- layout src
- return
- return (return this stack)
Written with StackEdit.
Saturday, September 10, 2016
在linux上製作win10 live USB
在linux上製作win10 live USB
這部份很簡單,只要記住一個重要的程式『winusb』,安裝這個程式,一切都簡單。
首先,以arch linux 為例,winusb是在aur裡,所以只要下:
yaourt -Sy winusb
即可安裝。
接著開始製作live usb,先找到win10 ISO 檔的路徑,還有你的隨身碟隨身碟掛載路徑,下以下指令:
winusb --install <iso path> <partition>
記得要用root or sudo來做。即可完成。
Wednesday, August 31, 2016
Jekyll 一些問題解法
用github架Jekyll 一些問題解法
當一開始使用
的時候,可能會遇到一些問題(其實是我遇到的啦)
jekyll serve not found
這是一個很好處理的問題,因爲你的~/.gem/ruby/{version}/bin資料夾沒有在$PATH路徑下。加上去就可解決了。
缺少bundler
大概的error如上。處理方式很簡單,就是安裝bundler。
這樣就解決了。
如果還有以下錯誤:
resolver.rb:356:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'jekyll-sitemap' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)
則多下一行指令:
$ bundle install --path vendor/bundle
如果還有以下錯誤:
resolver.rb:356:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'jekyll-sitemap' in any of the gem sources listed in your Gemfile or available on this machine. (Bundler::GemNotFound)
則多下一行指令:
$ bundle install --path vendor/bundle
invalid date ...YAML..
跑jekyll serve的時候可能會有噴出一堆如下的錯誤。
處理方法稍微麻煩一點。找到repo底下的_config.yml檔案,在約第五行
...
...
...exclude:[......,"vendor"...]
的exclude中加入vendor。
assets/themes/bootstrap-3下,但其原本目錄並沒有這個子目錄,所以在assets/themes下建立bootstrap-3,並將原本的bootstrap移到底下。
...
...
...exclude:[......,"vendor"...]
的exclude中加入vendor。
一些asset link出錯
我自己在架的時候他的一些bootstrap的css和js檔案link不到,原因是它要link的連結在assets/themes/bootstrap-3下,但其原本目錄並沒有這個子目錄,所以在assets/themes下建立bootstrap-3,並將原本的bootstrap移到底下。
Subscribe to:
Posts (Atom)
精選文章
使用Ardunio Atmega2560 連接 nRF24L01+
使用Ardunio Atmega2560 連接 nRF24L01+ 關於library 目前主流有 https://github.com/maniacbug/RF24 與 https://github.com/TMRh20/RF24 這兩個。 其中TMRh20大大做...
-
John Murphy:異軍突起的電影配樂家 首先先貼他的個人網站 http://johnmurphyofficial.com/ 。 本文的音樂都在這: http://www.johnmurphyofficial.com/tunesbox_1.html 他最有名...
-
STM32 LCD 使用 BSP 與STM32CubeMX 本文以STM32F469NI Discovery為範例。目標是以STM32F469的BSP lib操作STM32F469 Discovery的TFT-LCD。 STM32CubeMX configuratio...
-
PWM簡述 PWM為Pulse Width Modulation的縮寫,對於只有high和low的數位訊號來說,如何用high,low比率調整出類似類比訊號為PWM的用處,另外大多數馬達也透過PWM來驅動轉速,LED由於只吃固定電壓,所以常用PWM來調整亮度。 du...