va_end is undefined

Even after including stdarg.h, and when every other function in it works, it keeps saying va_end is undefined. Am I doing something wrong? Here is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//////////.h
#pragma once
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <string>

#define PRINTF_DEBUG_S(string_data)\
printfDebugMac(__FILE__, __LINE__, "%s", string_data);

void printfDebugMac(const char* file, int line, const char* format, ...);

void printfDebug(const char* format, ...);


//////////.cpp
#include "Utilities.h"

void printfDebugMac(const char* file, int line, const char* format, ...)
{
#if defined(DEBUG_PRINT) || defined(DEBUG)
	//char* file_correct = strrchar(file, "/");
	int poop = std::string(file).find_last_of("/");
	char buffer[2056];
	va_list al;
	va_start(al, format);
	vsprintf(buffer, format, al);
	va_end(al);
#endif
}

void printfDebug(const char* format, ...)
{
#if defined(DEBUG_PRINT) || defined(DEBUG)
	va_list al;
	va_start(al, format);
	vprintf(format,al);
	va_end{al);
#endif
}



This is in Ubuntu 15.10
Here is my gcc and g++ info

1
2
3
4
5
6
7
8
g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) 

You have used a curly bracket instead of a regular parenthesis.

1
2
va_end{al);
      ^

The reason for the unhelpful error message is probably because va_end is a macro.
Last edited on
Topic archived. No new replies allowed.