小编pad*_*ony的帖子

在C中链接文件/标题

假设我有以下程序(hello.c):

#include <stdio.h>
#include <math.h>

#define NAME "ashoka"


int main(int argc, char *argv[])
{
    printf("Hello, world! My name is %s\n", NAME);
}
Run Code Online (Sandbox Code Playgroud)

所以,据我所知,编译这个程序的过程是:

  1. 预处理:将复制粘贴stdio.hmath.h函数声明并替换NAME"ashoka".

    clang -E hello.c
    
    Run Code Online (Sandbox Code Playgroud)
  2. 编译:将代码转换为汇编代码

    clang -S hello.c
    
    Run Code Online (Sandbox Code Playgroud)

    生成的文件:hello.s

  3. 组装:将汇编代码转换为目标代码

    clang -c hello.s
    
    Run Code Online (Sandbox Code Playgroud)

    生成的文件:hello.o

  4. 链接:将目标文件合并到一个我们将要执行的文件中.

    clang hello.o -lm
    
    Run Code Online (Sandbox Code Playgroud)

    或者(假设我也想链接hello2.o)

    clang hello.o hello2.o
    
    Run Code Online (Sandbox Code Playgroud)

所以,问题来了:

  1. 该过程描述的是正确的吗?

  2. 在链接阶段,我们将.o(对象代码)文件链接在一起.我知道它 …

c linux linker compilation clang

11
推荐指数
1
解决办法
316
查看次数

指针在C中的价值

我已经开始学习C(所以,你知道..指针).

我有这个代码:

#include <stdio.h>
#include <string.h>

int main (int argc, char* argv[])
{
    char c = 'c';
    char* cptr = &c;

    printf("c = %c\n", c);
    printf("*cptr = %c\n", *cptr);  
    printf("c address = %p\n", &c);  
}
Run Code Online (Sandbox Code Playgroud)

我的输出是:

c = c
*cptr = c
c address = 0x7fff0217096f
Run Code Online (Sandbox Code Playgroud)

当我将上面的十六进制转换为十进制时,我得到:140720994002157

我的问题:

1)这个十进制值是否代表内存地址?不是太大了吗?

2)如何将指针的值(表示c变量的地址)打印为小数?

c pointers memory-address

9
推荐指数
1
解决办法
4363
查看次数

Heroku 403 Forbidden Error

我部署了一个PHP应用程序,当我点击url时,我收到以下错误:

Forbidden

You don't have permission to access / on this server.
Run Code Online (Sandbox Code Playgroud)

我想它试图进入app /目录,但它不能.


我的项目结构:

my-project
|
|-> app/
|-> public/ (index.php inside here that takes care of routing)
Procfile
composer.json
etc.
Run Code Online (Sandbox Code Playgroud)

日志显示的内容:

Jul 24 12:44:08 cryptic-beyond-39147 app/web.1:  [Sun Jul 24 19:44:07.846582 2016] [autoindex:error] [pid 99:tid 139960748263168] [client 10.179.164.130:28253] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive 
Jul 24 12:44:08 cryptic-beyond-39147 app/web.1:  10.179.164.130 - - [24/Jul/2016:19:44:07 +0000] "GET / HTTP/1.1" …
Run Code Online (Sandbox Code Playgroud)

php .htaccess routing heroku

7
推荐指数
2
解决办法
9528
查看次数

无需登录即可获取访问令牌| Facebook`

我正在创建一个Web应用程序,我需要拨打这样的电话: https://graph.facebook.com/639339682906611?access_token={my_access_token_here}

当我通过Graph API Explorer获取access_token时,它可以正常工作。但是过了一段时间(我认为是几天)之后,令牌过期了,我不得不再次手动进入Graph API Explorer来对其进行更新。

该网络应用无需用户登录。

有没有一种方法可以自动更新我的access_token?如果没有,是否有办法使我的access_token持续更长的时间?

facebook facebook-graph-api facebook-php-sdk facebook-access-token

3
推荐指数
1
解决办法
1万
查看次数