请注意,这与名为generic makefile的其他问题不重复.
我已经遵循了有关通用makefile的其他问题的所有说明,这是我从中得出的代码:
CFLAGS = -c
CC = cc
SOURCES = $(wildcard *.cc)
OBJECTS = $(patsubst %.cc,%.o,%(SOURCES))
EXEC = run
all: build clean
build: $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.cc
$(CC) $(CFLAGS) $<
clean:
rm *.o
Run Code Online (Sandbox Code Playgroud)
但是,当我make使用test.cc我的目录中调用的文件执行时,它会给我一个followig错误:
cc -o run
cc: error: no input files
*** Error code 1
Stop.
make: stopped in /somewhere
Run Code Online (Sandbox Code Playgroud)
请注意我在FreeBSD上,make而cc命令是操作系统附带的命令.
我在 Laravel 中有邮件发送功能
public static function Compose($to,$cc,$bcc,$subject,$body)
{
// return $to;
try
{
$data = [
'body' => $body
];
if(env('APP_ENV') == "local")
{
$email["subject"] = $subject;
$email["to"] = $to;
$email["cc"] = $cc;
$email["bcc"] = $bcc;
Mail::send('email.composeMail', $data, function ($message) use ($email) {
$message
->subject($email["subject"])
->to($email["to"]);
->cc($email["cc"]);
->bcc($email["bcc"]);
});
}
else
{
$email["subject"] = $subject;
$email["to"] = $to;
$email["cc"] = $cc;
$email["bcc"] = $bcc;
Mail::send('email.composeMail', $data, function ($message) use ($email) {
$message
->subject($email["subject"])
->to($email["to"]);
->cc($email["cc"]);
->bcc($email["bcc"]);
});
}
}
catch …Run Code Online (Sandbox Code Playgroud) 当我.c使用该cc命令编译文件时,它会创建一个a.out可执行文件.我注意到它a.out在我当前目录中创建了文件.有没有办法让a.out文件在与.c我在系统上的任何地方的文件相同的目录中创建?
例如,如果我当前的路径是~/desktop,我输入命令:
cc path/to/my/file/example.c
Run Code Online (Sandbox Code Playgroud)
它a.out在~/desktop目录中创建文件.我想在它中创建a.out文件path/to/my/file/a.out
我有一个头文件,包括这样的结构:
typedef struct
{
int index = -1;
stack_node *head;
} stack;
Run Code Online (Sandbox Code Playgroud)
但是当使用cc进行编译时,它会在赋值行(int index = -1)处显示错误:
error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
Run Code Online (Sandbox Code Playgroud)
我应该添加初始化函数来初始化变量吗?
我正在尝试将文件写入磁盘,然后自动重新编译.不幸的是,似乎没有用,我收到的错误信息我还不明白(我是C初学者:-).如果我手动编译生成的hello.c,它一切正常吗?!
#include <stdio.h>
#include <string.h>
int main()
{
FILE *myFile;
myFile = fopen("hello.c", "w");
char * text =
"#include <stdio.h>\n"
"int main()\n{\n"
"printf(\"Hello World!\\n\");\n"
"return 0;\n}";
system("cc hello.c -o hello");
fwrite(text, 1, strlen(text), myFile);
fclose(myFile);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o:在函数_start':
(.text+0x20): undefined reference tomain中'collect2:ld返回1退出状态
是不可能在main()中定义结构.我尝试以下只是为了获得分段错误:
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#define TRUE 1
void main(int argc,char **argv)
{
struct test_struct
{
char test_name[50];
char summary_desc[200];
char result[50];
};
struct suite_struct
{
char suite_name[50];
struct test_struct test[500];
int test_count;
int passed;
int failed;
int unresolved;
int notrun;
}suite[500];
int a,b;
for (a=0;a<500;a++)
{
strcpy(suite[a].suite_name,"");
for (b=0;b<500;b++)
{
strcpy(suite[a].test[b].test_name,"");
strcpy(suite[a].test[b].summary_desc,"");
strcpy(suite[a].test[b].result,"");
}
suite[a].test_count=0;
suite[a].passed=0;
suite[a].failed=0;
suite[a].unresolved=0;
suite[a].notrun=0;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我在其外部采用结构定义时,它的工作原理是:
#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#define TRUE 1
struct test_struct
{
char test_name[50];
char …Run Code Online (Sandbox Code Playgroud) 任何原因
cc -g -lm -DBLITZ_HOST_IS_LITTLE_ENDIAN
Run Code Online (Sandbox Code Playgroud)
使用代码会产生错误math.h吗?是否有可能GCC版本4.0.3(文档工作版本)和版本4.6.3(我当前版本)之间存在差异?
makefile和asm.c@ https://gist.github.com/3801291
这是在ubuntu 12.04上
我的终端输出是要点中的注释.
我正在处理有关链接的文本,并希望与所述文本中的一些示例一起工作。
为了更好地理解调用gcc驱动程序时发生了什么,我正在考虑手工完成所有的老式编译;
cppcc1 as ld不幸的是,在我的 Mac 上,我似乎无法cc1直接引用(没有列出cc1in man)。我有哪些选择?
我在更大的C程序中有以下代码.刚才我尝试编译时没有任何问题; 它在Minix 2.0.4中运行并使用编译cc.编译错误如下所示:
line 26: void not expected
Run Code Online (Sandbox Code Playgroud)
第26行只是一个函数声明main():
void initpool(void);
Run Code Online (Sandbox Code Playgroud)
initpool() 本身稍后在程序中使用此标头定义:
void
initpool(void)
{
Run Code Online (Sandbox Code Playgroud)
从我研究过的一切都应该是正确的,并gcc没有抛出编译错误.之前的所有行都以;s应该结束,所以这不是问题.为什么要cc编译它有问题?
编辑:根据要求,通向第26行的行如下(从main()第25行开始,第25行为空):
19: int
20: main(int argc, char *argv[])
21: {
22: int count, inserror;
23: olnode *list, *ptr;
24: list = NULL;
Run Code Online (Sandbox Code Playgroud) 发布的代码直接从流行的SDL2教程示例复制而来,以确保不是我犯了一些愚蠢的错误。我对示例所做的全部工作是更改有问题的图像文件的路径,我将类型bool更改为int,将false更改为0,将true更改为1。据我所知,不应保留任何C ++特定的内容。
无论我做什么,一切似乎都可以正常工作,但是在使用CC / GCC进行编译时(我想这实际上是同一笔交易),我怀疑在close()中最终会遇到分段错误,但我无法确定。使用G ++进行编译可以防止分段错误。
解决方案当然很简单,只需使用G ++,但我非常想知道问题出在哪里。
main.c:
//Using SDL and standard IO
#include <SDL2/SDL.h>
#include <stdio.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
//Starts up SDL and creates window
int init();
//Loads media
int loadMedia();
//Frees media and shuts down SDL
void close();
//The window we'll be rendering to
SDL_Window* gWindow = NULL;
//The surface contained by the window
SDL_Surface* gScreenSurface = NULL;
//The image we will load and show on the …Run Code Online (Sandbox Code Playgroud)