You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用GCC 4.3.5编译含可变参数模板的PSP代码报错求助

Fixing Variadic Template Compilation Errors with GCC 4.3.5

Hey there, let's break down why your code is throwing those errors and how to fix it.

What's Causing the Issue?

The errors you're seeing:

main.cpp:12: error: ISO C++ does not include variadic templates
main.cpp:13: error: ISO C++ does not include variadic templates

Happen because variadic templates are a C++11 feature, and GCC 4.3.5 defaults to using the older C98 standard (which doesn't support C11 additions like variadic templates).

Solution 1: Enable C++11 Support in Your Compiler

GCC 4.3.x has partial support for C11, you just need to tell it to use the newer standard. Add the -std=c++0x flag to your compile command (early GCC versions used c++0x as the flag for the then-unreleased C11 standard).

For example, your compile command might look like this:

g++ -std=c++0x main.cpp -o controltest.pbp [your other PSP build flags]

This should let the compiler recognize the variadic template syntax and fix the errors.

Solution 2: Rewrite the Code Without Variadic Templates

If you'd rather avoid relying on C++11 (maybe for broader compatibility), you can replace the variadic template with a regular function that matches your current usage:

#include <pspkernel.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <string.h>

PSP_MODULE_INFO("CONTROLTEST", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

int done = 0;

// Replace the variadic template with a simple function
void Printf(int num) {
    pspDebugScreenPrintf("Test %d\n", num);
}

int main(void) {
    pspDebugScreenInit();
    Printf(1);
    while(!done){ }
    sceKernelExitGame();
    return 0;
}

If you need to support more parameter types or counts later, you can just overload the Printf function:

// Overload for strings
void Printf(const char* message) {
    pspDebugScreenPrintf("%s\n", message);
}

// Overload for int + string
void Printf(int num, const char* message) {
    pspDebugScreenPrintf("Test %d: %s\n", num, message);
}

Quick Note

If you plan to use more C11 features down the line, consider upgrading your GCC version—GCC 4.8 and later have much better full support for C11. Just make sure any upgraded compiler works with your PSP cross-compilation setup.

内容的提问来源于stack exchange,提问作者user11922539

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:37:45