首页 \ 问答 \ C中使用_start()是什么?(What is the use of _start() in C?)

C中使用_start()是什么?(What is the use of _start() in C?)

从我的同事那里得知,可以编写和执行一个C程序,而无需编写一个main()函数。 它可以做到下面

withoutMain.c

// Compile it with gcc -nostartfiles

void _start() {
  int ret = my_main();
  exit(ret); 
}

int my_main() {
  puts("This is a program without main!\n");
  return 0; 
}

编译为: gcc -o withoutMain withoutMain.c –nostartfiles

运行它: ./ withoutMain

我的问题是什么时候需要做这样的事情? 一些现实世界的场景?


I learned from my colleague that one can write and execute a C program without writing a main() function. It can be done like this:

my_main.c

/* Compile this with gcc -nostartfiles */

#include <stdlib.h>

void _start() {
  int ret = my_main();
  exit(ret); 
}

int my_main() {
  puts("This is a program without a main() function!");
  return 0; 
}

Compile it with this command:

gcc -o my_main my_main.c –nostartfiles

Run it with this command:

./my_main

When would one need to do this kind of thing? Is there any real world scenario where this would be useful?


原文:https://stackoverflow.com/questions/29694564
更新时间:2022-08-15 13:08

最满意答案

从GitHub支持,2014-06-07:

目前不可能手动触发重建,而不会将提交推送到相应的分支。


编辑:

正如Andy在评论中指出的那样,您可以使用以下命令推送一个空提交:

git commit -m 'rebuild pages' --allow-empty

From GitHub support, 2014-06-07:

It's not currently possible to manually trigger a rebuild, without pushing a commit to the appropriate branch.


Edit:

As Andy pointed out in the comments, you can push an empty commit with the command:

git commit -m 'rebuild pages' --allow-empty
git push origin <branch-name>

相关问答

更多
  • 看起来这个宝石提供了一个优雅的解决方案: 中间人-GH-页 Looks like this gem provides an elegant solution: middleman-gh-pages
  • 这在“ 页面构建失败:缺少子模块 ”中提到。 您可以看到子模块是否初始化为: cd /path/to/main/repo git submodule init git submodule update 但是如果你没有任何.gitmodules,那么它实际上是一个嵌套的git仓库,你需要先删除那个项目(如果你真的需要它),把它作为一个合适的子模块 cd /path/to/main/repo git rm mysubmodule # no trailing slash git submodule add ...
  • 要更好地控制您的网站的缓存,您可以使用HTML5缓存清单。 看到: HTML5 应用缓存使用入门指南 在Mozilla开发人员网络上使用应用程序缓存 在维基百科上的HTML5缓存清单 离线Web应用程序 W3C工作组注释 离线Web应用程序在WHATWG 您可以使用window.applicationCache.swapCache()来更新网站的缓存版本,而无需手动重新加载页面。 这是HTML5 Rocks的代码示例,解释如何将用户更新到您网站的最新版本: // Check if a new cache i ...
  • 从GitHub支持,2014-06-07: 目前不可能手动触发重建,而不会将提交推送到相应的分支。 编辑: 正如Andy在评论中指出的那样,您可以使用以下命令推送一个空提交: git commit -m 'rebuild pages' --allow-empty From GitHub support, 2014-06-07: It's not currently possible to manually trigger a rebuild, without pushing a commit to the ...
  • 有一个github-pages gradle插件 ,非常容易用于在gradle构建中向gh-pages分支发布文档,我过去成功使用过它。 There's a github-pages gradle plugin that is extremely easy to use to publish documentation to gh-pages branch in gradle builds and I've successfully used it in the past.
  • 找到了答案 - https://github.com/blog/572-bypassing-jekyll-on-github-pages 只需要在回购中包含一个.nojekyll文件 Found an answer -https://github.com/blog/572-bypassing-jekyll-on-github-pages Just needed to include a .nojekyll file in the repo
  • “石板”主题只有一个“默认”布局。 所以切换到layout: default解决了问题。 The "slate" theme only has a "default" layout. So switching to layout: default fixed the issues.
  • 对于本地构建,您必须使用bundle update来更新gem。 你会看到你有一个'荧光笔'警告。 关于github-pages。 我只是分叉你的回购 ,它只用相同的突出显示警告构建 (只需很小的修改): 页面构建成功完成,但返回以下警告:您正在尝试使用'pygments'荧光笔,目前GitHub页面上不支持该荧光笔。 您的网站将使用“rouge”代替突出显示。 要取消此警告,请在“_config.yml”中将“highlighter”值更改为“rouge”,并确保未设置“pygments”键。 有关更多信 ...
  • 我无法弄清楚为什么github页面突然无法构建这个模板,但我找到了一个解决方法,通过在本地编译页面并将其推送到github。 本文提供了有关如何使用此技术发布到github页面的分步指南。 基本上,您需要使用本地Rakefile中的以下脚本进行本地编译和推送: require "rubygems" require "tmpdir" require "bundler/setup" require "jekyll" # Change your GitHub reponame GITHUB_REPONAME ...
  • 每个Jekyll主题都有不同的布局。 默认主题有四种布局: 默认 家 页 岗位 虽然其他布局可以具有相同的布局或不同的布局集,但在这种情况下,您选择的其他主题只有一个布局,它尊重其名称的最小部分(jekyll-theme-minimal): 默认 默认安装附带了几个使用不同布局的示例,如果您更改为jekyll-theme-minimal ,则只有一个布局可用(除非您自己添加更多)。 Each Jekyll theme has a different set of layouts. The default t ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)