ページ 1 / 1
gcc/g++の使い方
Posted: 2010年9月06日(月) 22:38
by pon
g++ -O2 -Wall -Wextra ~.cpp -o ~
.cppをcompileする時、自分は毎回こうします。
bash_profileをいじれば良いと言う話を聞いたのですが、どうすればいいのでしょうか。
compilerはcygwinを使っています
Re:gcc/g++の使い方
Posted: 2010年9月07日(火) 01:01
by たかぎ
> どうすればいいのでしょうか。
どうなってほしいのでしょうか?
Re:gcc/g++の使い方
Posted: 2010年9月07日(火) 10:09
by さかまき
bash_profileをいじれば
(毎回、「g++ -O2 -Wall -Wextra ~.cpp -o ~」をキーインする必要は無くて具合が)
良いと言う話を聞いたの
でしたら、たぶん .bash_profile 等に
function cppWallWextra () { g++ -O2 -Wall -Wextra $@.cpp -o $@ }
などと記述しておけば具合がよいのじゃないかというような話だと思います。
(bash_profileをいじれば良いと言う話を聞いた時に突っ込んで詳細を聞いておけばよかったですね)
Re:gcc/g++の使い方
Posted: 2010年9月09日(木) 18:15
by pon
それをコピペしてbash_profileの最後に貼り付けてもうまくいかないんですけどどうすれば良いですか
Re:gcc/g++の使い方
Posted: 2010年9月09日(木) 20:13
by Poco
> それをコピペしてbash_profileの最後に貼り付けてもうまくいかないんですけどどうすれば良いですか
たかぎさんも尋ねられていますが、何をもって望みの結果となるか、明記していただけませんか?
そして、さかまきさんの提示された方法で、何をもって上手くいかないと判断したか、明記していただけませんか?
Re:gcc/g++の使い方
Posted: 2010年9月10日(金) 21:20
by pon
さかまきさんのおっしゃる通り毎回打たなくても良くなると聞きました
で、さかまきさんに教えていただいた1行を追加するだけでは、cygwinを起動するときにunexpected end of lineと出てうまく読み込めなかったみたいです。
Re:gcc/g++の使い方
Posted: 2010年9月10日(金) 21:54
by Poco
関数定義を複数行に渡って記述してください。
function cppWallWextra () {
g++ -O2 -Wall -Wextra $@.cpp -o $@
}
----追記
エラーメッセージがでる理由は、関数定義の閉じカッコがg++のコマンドの一部と解釈されているからです。
ですので、コマンドの終りにセミコロンを入れても通ります。
function cppWallWextra () { g++ -O2 -Wall -Wextra $@.cpp -o $@; }

Re:gcc/g++の使い方
Posted: 2010年9月10日(金) 23:28
by pon
Errorが改善されないんですけど、functionの上が問題なんでしょうか。
# base-files version 3.9-3
# To pick up the latest recommended .bash_profile content,
# look in
/etc/defaults/etc/skel/.bash_profile
# Modifying /etc/skel/.bash_profile directly will prevent
# setup from updating it.
# The copy
in your home directory (~/.bash_profile) is yours, please
# feel free to customise it to create a shell
# environment to your liking.
If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.
# ~/.bash_profile:
executed by bash for login shells.
# source the system wide bashrc if it exists
if [ -e /etc/bash.bashrc ] ; then
source
/etc/bash.bashrc
fi
# source the users bashrc if it exists
if [ -e "${HOME}/.bashrc" ] ; then
source "${HOME}/.bashrc"
fi
# Set
PATH so it includes user's private bin if it exists
# if [ -d "${HOME}/bin" ] ; then
# PATH=${HOME}/bin:${PATH}
# fi
# Set
MANPATH so it includes users' private man if it exists
# if [ -d "${HOME}/man" ]; then
#
MANPATH=${HOME}/man:${MANPATH}
# fi
# Set INFOPATH so it includes users' private info if it exists
# if [ -d
"${HOME}/info" ]; then
# INFOPATH=${HOME}/info:${INFOPATH}
#