将经过默认参数提升的对象传递给“ va_start”

时间:2019-10-09 09:09:23

标签: ios objective-c iphone xcode

这是我的第一个Xcode应用程序和Objective-c,所以请给我一些时间:)

我尝试在该问题上进行搜索,但是看不到有关Xcode和应用程序开发的任何帮助。我在//

之后添加了错误信息
- (id)initWithBytes:(int8_t)byte1, ... { //Error: 1. Parameter of type 'int8_t' (aka 'signed char') is declared here
  va_list args;
  va_start(args, byte1); //Error: Passing an object that undergoes default argument promotion to 'va_start' has undefined behavior
  unsigned int length = 0;
  for (int8_t byte = byte1; byte != -1; byte = va_arg(args, int)) {
    length++;
  }
  va_end(args);

  if ((self = [self initWithLength:length]) && (length > 0)) {
    va_list args;
    va_start(args, byte1); // Error: Passing an object that undergoes default argument promotion to 'va_start' has undefined behavior
    int i = 0;
    for (int8_t byte = byte1; byte != -1; byte = va_arg(args, int)) {
      _array[i++] = byte;
    }
    va_end(args);
  }
 return self;
}

提前谢谢!

0 个答案:

没有答案