Thread: Compiler bug?
View Single Post
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 05-03-2009 , 17:03   Re: Compiler bug?
Reply With Quote #9

If your array holds handles, you should declare it as "new Handle:g_hCvarsList[CvarsList]" instead of leaving it untagged or forcing the tag in the function. Tagging your enum values as handles shouldn't accomplish anything.

The following three files compile fine exactly as so:

test.sp
PHP Code:
#include <sourcemod>
#include "file1"
#include "file2"

public OnPluginStart()
{
        
ConfigGetFilePath(CVAR_CONFIG_PATH_1"");

file1.inc
PHP Code:
/**
 * List of cvars used by the plugin.
 */
enum CvarsList
{
           
CVAR_CONFIG_PATH_1,
           
CVAR_CONFIG_PATH_2,
           
CVAR_CONFIG_PATH_3,
           
CVAR_CONFIG_PATH_4,
           
CVAR_CONFIG_PATH_5,
           
CVAR_CONFIG_PATH_6,
           
// Many more handles, but again, irrelevant.
}

/**
 * Array to store cvar data in.
 */
new Handle:g_hCvarsList[CvarsList]; 
file2.inc
PHP Code:
/**
 * Load config file.
 *
 * @param file  The cvar define of the path to the file.
 * @return      True if the file exists, false if not.
 */
bool:ConfigGetFilePath(CvarsList:cvarString:path[])
{
        
// Get cvar's path.
        
decl String:filepath[PLATFORM_MAX_PATH];
        
GetConVarString(g_hCvarsList[cvar], filepathsizeof(filepath));

        
// Build full path in return string.
        
BuildPath(Path_SMpathPLATFORM_MAX_PATHfilepath);

        return 
FileExists(path);

If the Handle tag is removed from the array declaration, a tag mismatch warning will be emitted.
Fyren is offline