小编Han*_*ank的帖子

如何在C++中调用带有"parameter = value"的函数?

阅读代码时,我们会找到一些这样的函数.

g_spawn_async(NULL, new_argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
Run Code Online (Sandbox Code Playgroud)

我想没有人能弄清楚每个参数的含义是什么.为了理解代码,我们必须找到函数的声明.

gboolean    g_spawn_async               (const gchar *working_directory,
                                         gchar **argv,
                                         gchar **envp,
                                         GSpawnFlags flags,
                                         GSpawnChildSetupFunc child_setup,
                                         gpointer user_data,
                                         GPid *child_pid,
                                         GError **error);
Run Code Online (Sandbox Code Playgroud)

我们如何在C++中调用类似以下格式的函数?

g_spawn_async(working_directory=NULL,
              argv=new_argv,
              envp=NULL,
              flags=G_SPAWN_SEARCH_PATH,
              child_setup=NULL,
              user_data=NULL,
              child_pid=NULL,
              error=NULL);
Run Code Online (Sandbox Code Playgroud)

我认为这个将更具可读性,我可以理解代码而无需查找函数的声明.

我知道Python可以做到这一点.C++如何做到这一点?

c c++ function

12
推荐指数
2
解决办法
497
查看次数

为什么 gradle lint 认为省略号字符“…” 比“...”更具可读性?

我在 string.xml 中定义了一个字符串 "XXX..." 并得到一个 gradle lint 问题。

Replace "..." with ellipsis character (…, …) ?
Explanation: Ellipsis string can be replaced with ellipsis character.
You can replace the string "..." with a dedicated ellipsis character,
ellipsis character (…, …). This can help make the text more readable. 
Run Code Online (Sandbox Code Playgroud)

为什么“...”比“...”更具可读性?当有人看到“…”时,我认为他/她不会意识到这是一个省略号。

android lint gradle

2
推荐指数
1
解决办法
1369
查看次数

我怎么能只写一次"#include"?

在一些大型C++项目中,有许多#include指令.例如,

#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
Run Code Online (Sandbox Code Playgroud)

我必须#include在这个例子中写四个.我很懒,我只想写一次.也许是这样的:

#include {
    <iostream>
    <boost/asio.hpp>
    <boost/bind.hpp>
    <boost/date_time/posix_time/posix_time.hpp>
}
Run Code Online (Sandbox Code Playgroud)

有没有办法像这样做?或者我们可以定义一个宏来做到这一点吗?

c++ macros c-preprocessor

1
推荐指数
2
解决办法
541
查看次数

标签 统计

c++ ×2

android ×1

c ×1

c-preprocessor ×1

function ×1

gradle ×1

lint ×1

macros ×1