小编mar*_*olz的帖子

使用ssize_t vs int

码

我有一个函数,我可以用以下四种方式之一编写:

    int do_or_die(int retval);
    int do_or_die(ssize_t retval);
    ssize_t do_or_die(int retval);   
    ssize_t do_or_die(ssize_t retval);   
Run Code Online (Sandbox Code Playgroud)

然后,它将使用这两种方式调用库函数:

    written = do_or_die(write(...)); // POSIX write returns ssize_t
    printed = do_or_die(printf(...)); // printf returns int
Run Code Online (Sandbox Code Playgroud)

问题

  • 我应该使用哪种原型?
  • 我应该给什么类型written和printed?

我希望拥有最强大和标准的代码,同时仍然只有一个do_or_die功能.

我在这种情况下使用C99,但如果C11的答案不同,那么我也想知道这一点,以备将来使用.

c standards type-conversion

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

Traefik-如何记录request_body

我是Traefik的新手,正在尝试寻找一种捕获和记录request_body的方法。在Nginx中,通过在nginx.conf中添加$ request_body,它将把正文记录在access.log中。在特拉菲克这可能吗?

谢谢

traefik

5
推荐指数
0
解决办法
191
查看次数

移动Safari中的文件上传和EXIF

正如这些问题所指出的,在某些情况下,iOS上的foto上传文件的地理位置和其他EXIF元数据已被删除(在野生动物园中):

https://apple.stackexchange.com/questions/326789/gps-exif-from-iphone-photo-upload-in-safari

从iPhone上传的图片会剥离EXIF数据

截至目前,我还没有找到适当的情况描述。我有2台设备用于测试安装了最新iOS的设备,其中未剥离EXIF元数据。

是否有办法确定(最好是在浏览器中或从上载中)是否已删除元数据以便向用户显示某种信息?

file-upload mobile-safari ios

5
推荐指数
1
解决办法
228
查看次数

如何使用layoutDirection在Android中动态镜像整个布局?

我试图建立一个android应用程序的前端视图。我必须将整个显示动态地推到屏幕的右侧。

我想将整个相对布局推到屏幕的右侧。

以下是我的XML代码:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/message_single_layout"
        android:padding="10dp"
        android:layout_gravity=""
        android:weightSum="10">
        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/message_profile_layout"
            android:layout_width="36dp"
            android:layout_height="36dp"
            android:layout_weight="0"
            android:src="@drawable/default_avatar" />

        <TextView
            android:layout_alignParentRight="true"
            android:id="@+id/message_text_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/name_text_layout"
            android:layout_marginLeft="10dp"
            android:layout_toEndOf="@+id/message_profile_layout"
            android:padding="10dp"
            android:background="@drawable/their_message"
            android:text="Message Text"
            android:textColor="@color/colorPrimary"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/name_text_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="10dp"
            android:layout_toEndOf="@+id/message_profile_layout"
            android:text="Display Name"
            android:textColor="@android:color/black"
            android:textSize="15sp"
            android:textStyle="bold"

            />

        <TextView
            android:id="@+id/time_text_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/message_text_layout"
            android:layout_marginStart="-15dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="4dp"
            android:layout_toEndOf="@+id/name_text_layout"
            android:text="00:00"
            android:textSize="12sp" />

        <ImageView
            android:id="@+id/message_image_layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/message_text_layout"
            android:layout_alignStart="@+id/message_text_layout"
            android:layout_alignParentEnd="true"
            android:layout_marginStart="0dp"
            android:layout_marginLeft="0dp"
            android:layout_marginTop="-6dp"
            android:layout_marginEnd="9dp"
            android:layout_toEndOf="@+id/message_profile_layout"
            android:padding="0dp"
            android:scaleType="centerCrop" />

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我想动态地做。我试图改变gravity …

java xml android android-layout

4
推荐指数
1
解决办法
132
查看次数

我该如何解决这个问题:UILabel.text 必须仅在主线程中使用

所以我正在尝试更新我的应用程序中的 UI。发生的情况是标签会更新,但是当它们不保留自己的值但有时会采用另一个标签的值时。另外,我收到消息说标签只能从主线程使用,我该如何解决这个问题?

这是我的代码:

let queue = DispatchQueue(label: "update")
queue.async {
   for s in self.fietshare.stands {
      for b in s.bikes {
         lbAvailable.text = "Available Bikes: " + String(s.id) +  "  " + String( s.bikes.count) // shows too big numbers
         nrOfAvailable.text =  String(b.distance) + "M"
         annotationView.layoutIfNeeded()
         print(s.id)
         print("Nr of bikes")
         print(s.bikes.count)
      }
   }
}

DispatchQueue.main.async {
   self.view.backgroundColor = . black;
   self.view.layoutIfNeeded()
}

if (Thread.current.isMainThread) {
    print("Main thread")
}
Run Code Online (Sandbox Code Playgroud)

multithreading swift

4
推荐指数
1
解决办法
4220
查看次数

为什么我们在Objective-C或C语言中使用双指针和三指针?

当我想要单指针时我感到困惑,何时我应该采用双指针?在以下结构中究竟做了什么?

struct objc_class {
    Class isa;
    Class super_class;
    const char *name;
    long version;
    long info;
    long instance_size;
    struct objc_ivar_list *ivars;
    struct objc_method_list **methodLists;
    struct objc_cache *cache;
    struct objc_protocol_list *protocols;
};
Run Code Online (Sandbox Code Playgroud)

为什么我们使用"**methodLists"双指针.

编辑 int sqlite3_get_table(sqlite3*db,
const char*zSql,
char***pazResult,
int*pnRow,
int*pnColumn,
char**pzErrmsg
); 在上面的场景中,三指针char***pazResult的含义是什么?

c iphone objective-c

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

pywintypes.error:(50,'GetFileSecurity','不支持该请求。')在网络驱动器上使用Jupyter Notebook时

我目前正在尝试在网络驱动器上使用miniconda + jupyter(与pip一起安装)的组合,但出现以下错误:

pywintypes.error:(50,“ GetFileSecurity”,“不支持该请求。”)

我目前在公司环境中工作,因此我们在访问权限方面存在一些限制。不幸的是,我只能在网络驱动器上尝试使用jupyter,更改本地硬盘驱动器需要我没有的管理员权限。

完整的错误输出:

Traceback (most recent call last):
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\web.py", line 1699, in _execute
   result = await result
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
   yielded = self.gen.throw(*exc_info)  # type: ignore
 File "c:\programs\miniconda3_64\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
   type=mtype))
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 735, in run
   value = future.result()
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 742, in run
   yielded = self.gen.throw(*exc_info)  # type: ignore
 File "c:\programs\miniconda3_64\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
   kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
 File "c:\programs\miniconda3_64\lib\site-packages\tornado\gen.py", line 735, …
Run Code Online (Sandbox Code Playgroud)

python network-drive jupyter-notebook

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

如何在批处理文件中运行powershell命令

@ECHO off

$BIOS= Get-WmiObject -computername "BAHRIATSG2-PC" -Namespace 
root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface

$BIOS.SetBIOSSetting('Setup Password','<utf-16/>TheBIOSPassword','<utf-16/>')

pause
Run Code Online (Sandbox Code Playgroud)

当我另存为.bat文件并运行时,它将无法正常运行,否则当我手动输入时,它将在Powershell中正常运行。

powershell batch-file

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

C Linux 检查挂载中的可用空间

当我运行时df -h,我可以看到/dev我使用 6M 且大小为 40M ,可用大小为 34M 。

我怎样才能用c代码获取这些信息?

c linux mount

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

如何在打字稿中单击表格内的按钮时获取动态表格行数据

我正在使用动态表,每行都有一个按钮,单击按钮时,我需要单击的相应行按钮的数据。

我尝试过(单击)事件绑定,但输出为未定义。

<table>
<thead> <tr> <th> Name </th> <th> Company </th> </tr> </thead>
<tr *ngFor = "let employee of employees" (click) = "removeEmployee(row)">
            <td> <input type="text" [(ngModel)]= "employee.name"></td>
            <td> <input type="text" [(ngModel)] = "employee.companyName"> </td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)

.ts 文件

removeEmployee(tr) {
      console.log(tr);
    }
Run Code Online (Sandbox Code Playgroud)

预期:单击按钮时,应输出表行数据。

显示实际:未定义。

html-table typescript angular

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

在C语言中,变量的多次初始化不会引发错误。为什么?

在下面的代码中,变量被多次初始化。

为什么此代码不引发错误?

int main() 
{ 
  int x;
  x=5;
  x=10;
  printf("\nx=%d",x) ;
}
Run Code Online (Sandbox Code Playgroud)

节目输出

x = 10

c initialization

-4
推荐指数
1
解决办法
66
查看次数