我不明白为什么这样做是错的:
const int n = 5;
int x[n] = { 1,1,3,4,5 };
Run Code Online (Sandbox Code Playgroud)
即使n已经是const值.
虽然这样做似乎适合GNU编译器:
const int n = 5;
int x[n]; /*without initialization*/
Run Code Online (Sandbox Code Playgroud)
我知道C99的VLA功能,我认为这与正在发生的事情有关,但我只需要澄清背景中发生的事情.
即使我阅读了手册,我也很难理解FILES _ $ {PN}.例如,我正在研究制作启动脚本的这个例子.在我写了类似的东西之后,我收到了这些错误消息.
ERROR: initscriptd-1.0-r0 do_package: QA Issue: initscriptd: Files/directories were installed but not shipped in any package:
/usr
/usr/sbin
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
initscriptd: 2 installed and not shipped files. [installed-vs-shipped]
ERROR: initscriptd-1.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: initscriptd-1.0-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in: /home/yahia/Desktop/elinux_dev/bake_factory/poky-pyro-17.0.1/build/tmp/work/core2-64-poky-linux/initscriptd/1.0-r0/temp/log.do_package.5252
ERROR: Task (/home/yahia/Desktop/elinux_dev/bake_factory/poky-pyro-17.0.1/meta-mylayer/recipes-core/mylayer-initscript/initscriptd.bb:do_package) failed with …Run Code Online (Sandbox Code Playgroud) 我正在使用 Google 电子表格 API v4。我想通过 python 脚本删除一些行。我尝试了他们的示例代码,但出现以下错误
“requests[0].delete_dimension.range.sheet_id”处的值无效(TYPE_INT32)
我的代码:
batch_update_spreadsheet_request_body = {
"requests": [
{
"deleteDimension": {
"range": {
"sheetId": sheetId,
"dimension": "ROWS",
"startIndex": 0,
"endIndex": 3
}
}
},
{
"deleteDimension": {
"range": {
"sheetId": sheetId,
"dimension": "COLUMNS",
"startIndex": 1,
"endIndex": 4
}
}
},
],
}
request = sheets_service.spreadsheets().batchUpdate(spreadsheetId=sheetId, body=batch_update_spreadsheet_request_body)
response = request.execute()
Run Code Online (Sandbox Code Playgroud)
完整的追溯
回溯(最近一次调用):文件“/home/yahia/DSP_Project_Server_Software/python_scripts/TMSA/TMSA.py”,第 70 行,在 main() 文件“/home/yahia/DSP_Project_Server_Software/python_scripts/TMSA/TMSA.py”中,第 67 行,在主响应中 = request.execute() 文件“/usr/local/lib/python2.7/dist-packages/oauth2client/_helpers.py”,第 133 行,在 positional_wrapper 中 return wrapped(*args, ** kwargs) 文件“/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py”,第 840 行,在执行 raise HttpError(resp, content, …
假设我们有配方“A”和“B”,它们每个都在目标映像上安装一些二进制文件。但在图像的运行时, 'A' 的二进制结果取决于 'B' 的二进制结果是否存在。如果我这样做的话,我可以使两个二进制文件都存在
IMAGE_INSTALL_append = " A B"
Run Code Online (Sandbox Code Playgroud)
这很好用。但我想要的是使配方“A”在任何情况下都调用配方“B”,这样用户就不需要显得“A”需要“B”才能在图像上运行。例如,他只做
IMAGE_INSTALL_append = " A"
Run Code Online (Sandbox Code Playgroud)
我应该在配方“A”中做什么才能达到这种效果?
如果我写
//case 1
char *animals[2] = {"cat", "dog"};
char **animal_ptr = animals;
printf("%s\n", *(animal_ptr + 1)); //fine
Run Code Online (Sandbox Code Playgroud)
而且,以不同的方式:
//case 2
char *animal = "cat";
char **animal_ptr = &animal;
*(animal_ptr + 1) = "dog";
printf("%s\n", *(animal_ptr + 1)); //fine
Run Code Online (Sandbox Code Playgroud)
所以,我对上面的两个例子感到困惑.
在案例1中,我理解这animal_ptr是一个指向指针集合的指针,并且由于指针保存地址,我不需要添加&.但是在第2种情况下,我必须添加一个&for才能工作,即使animal它已经是一个指针.为什么?
在这两种情况下,为什么通过另一个可接受的指针修改字符串文字?据我所知,当你声明一个像char *x = "..etc";这样的字符串时,它被放在一个无法修改的内存中.那么,为什么在情况1,无论animal和animal_ptr可修改字符串?
为什么strcpy(*(animal_ptr + 1), "bird")失败,程序停止,即使任务在2中工作.?
在案例2中:
printf("%s", *animal_ptr),它工作正常,对我有意义.printf("%s", *animal),它会停止.为什么?谢谢,很抱歉很多问题.