相关疑难解决方法(0)

如何在Makefile中设置子进程的环境变量

我想更改这个Makefile:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test:
    NODE_ENV=test mocha         \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)

至:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test: NODE_ENV=test
test:
    mocha                   \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)

不幸的是,第二个不起作用(节点进程仍以默认值运行) …

shell makefile environment-variables target

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

带有类型或变量的"C"sizeof

最近看到有人赞扬另一个用户使用sizeof var而不是sizeof(type).我一直以为这只是一种风格选择.有什么显着差异吗?例如,具有f和ff的线被认为比具有g和gg的线更好:

 typedef struct _foo {} foo;

 foo *f = malloc(count * sizeof f);
 foo *g = malloc(sizeof(foo) * count);

 foo **ff = malloc(count * sizeof *ff);
 foo **gg = malloc(sizeof(foo*) * count);
Run Code Online (Sandbox Code Playgroud)

在我看来,第一组只是风格问题.但是在第二对线中,额外的第二个*很容易混淆乘法.

c coding-style sizeof

21
推荐指数
2
解决办法
2万
查看次数

在Makefile中设置环境变量时的@前缀

这是我到目前为止所得到的:

SPECS = $(shell find spec -iname "*_spec.js")

spec:
    @NODE_ENV=test \
    @NODE_PATH=lib \
    ./node_modules/.bin/expresso \
    $(TESTFLAGS) \
    $(SPECS)

cov:
    @TESTFLAGS=--cov $(MAKE) spec

.PHONY: spec cov
Run Code Online (Sandbox Code Playgroud)

输出: /bin/sh: @NODE_PATH=lib: command not found

如果我设置一个变量只是它工作正常.我究竟做错了什么?

makefile environment-variables

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