gcc/g++の使い方

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
pon

gcc/g++の使い方

#1

投稿記事 by pon » 15年前

g++ -O2 -Wall -Wextra ~.cpp -o ~
.cppをcompileする時、自分は毎回こうします。
bash_profileをいじれば良いと言う話を聞いたのですが、どうすればいいのでしょうか。
compilerはcygwinを使っています

たかぎ

Re:gcc/g++の使い方

#2

投稿記事 by たかぎ » 15年前

> どうすればいいのでしょうか。

どうなってほしいのでしょうか?

さかまき

Re:gcc/g++の使い方

#3

投稿記事 by さかまき » 15年前

bash_profileをいじれば
(毎回、「g++ -O2 -Wall -Wextra ~.cpp -o ~」をキーインする必要は無くて具合が)
良いと言う話を聞いたの
でしたら、たぶん .bash_profile 等に
function cppWallWextra () { g++ -O2 -Wall -Wextra $@.cpp -o $@ }
などと記述しておけば具合がよいのじゃないかというような話だと思います。

(bash_profileをいじれば良いと言う話を聞いた時に突っ込んで詳細を聞いておけばよかったですね)

pon

Re:gcc/g++の使い方

#4

投稿記事 by pon » 15年前

それをコピペしてbash_profileの最後に貼り付けてもうまくいかないんですけどどうすれば良いですか

Poco

Re:gcc/g++の使い方

#5

投稿記事 by Poco » 15年前

> それをコピペしてbash_profileの最後に貼り付けてもうまくいかないんですけどどうすれば良いですか

たかぎさんも尋ねられていますが、何をもって望みの結果となるか、明記していただけませんか?
そして、さかまきさんの提示された方法で、何をもって上手くいかないと判断したか、明記していただけませんか?

pon

Re:gcc/g++の使い方

#6

投稿記事 by pon » 15年前

さかまきさんのおっしゃる通り毎回打たなくても良くなると聞きました

で、さかまきさんに教えていただいた1行を追加するだけでは、cygwinを起動するときにunexpected end of lineと出てうまく読み込めなかったみたいです。

Poco

Re:gcc/g++の使い方

#7

投稿記事 by Poco » 15年前

関数定義を複数行に渡って記述してください。

function cppWallWextra () {
g++ -O2 -Wall -Wextra $@.cpp -o $@
}

----追記
エラーメッセージがでる理由は、関数定義の閉じカッコがg++のコマンドの一部と解釈されているからです。
ですので、コマンドの終りにセミコロンを入れても通ります。

function cppWallWextra () { g++ -O2 -Wall -Wextra $@.cpp -o $@; }
画像

pon

Re:gcc/g++の使い方

#8

投稿記事 by pon » 15年前

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}
#

閉鎖

“C言語何でも質問掲示板” へ戻る