AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Using sh_vector.h / CVector in a SourceMod extension (https://forums.alliedmods.net/showthread.php?t=160066)

Powerlord 06-24-2011 16:43

Using sh_vector.h / CVector in a SourceMod extension
 
I'm currently working on a SourceMod extension that currently uses Valve's CUtlVector. However, I'm actually copying some code from another extension file that already uses CVector from sh_vector.h, so I was looking to convert over to it.

My project is using the SourceMod sample extension from 1.3.7's source code.

When I try to compile the project in Visual Studio 2008, I have a slight problem.

The problem I'm having is this. On this line:
Code:

CVector<unsigned int> m_Votes;
I'm getting this error:
Quote:

error C2143: syntax error : missing ';' before '<'
Near the top of the file, I have this include:
Code:

#include <sh_vector.h>
I have verified that MMSOURCE18 is properly set, so sh_vector.h should be in the project's include paths (via "$(MMSOURCE18)\core\sourcehook" ). I've also tried using this include instead:
Code:

#include "sh_vector.h"
The file this code appears in is not extension.h/extension.cpp but does include extension.h.

What am I doing wrong here?

PM 06-24-2011 17:34

Re: Using sh_vector.h / CVector in a SourceMod extension
 
Hmm,

(1) Are there any other errors?
(2) What is the line right before the line you posted?
(3) CVector is in namespace SourceHook. Try

Code:

SourceHook::CVector<unsigned int> m_Votes;
or if it works and you don't want to repeat that all the time, put a
Code:

using namespace SourceHook;
after your #includes and before your other code.

Greetings,
PM

Powerlord 06-27-2011 13:19

Re: Using sh_vector.h / CVector in a SourceMod extension
 
Quote:

Originally Posted by PM (Post 1495616)
Hmm,

(1) Are there any other errors?
(2) What is the line right before the line you posted?
(3) CVector is in namespace SourceHook. Try

Code:

SourceHook::CVector<unsigned int> m_Votes;
or if it works and you don't want to repeat that all the time, put a
Code:

using namespace SourceHook;
after your #includes and before your other code.

Greetings,
PM

Sorry about not responding sooner. Too much TF2 = not enough of me working on this.

That seems to have mostly worked, but now I get a new error that I can only define as "strange" in sh_vector.h:
Code:

Error    1    error C2065: 'NULL' : undeclared identifier    d:\tf2server\dev\sourcemm\core\sourcehook\sh_vector.h    80    1    sdk

PM 06-27-2011 13:39

Re: Using sh_vector.h / CVector in a SourceMod extension
 
What is your #include order? Try including sh_vector.h later (in C++, NULL is not a language keyword, some header #defines NULL (0) or something like that).

Powerlord 06-27-2011 13:41

Re: Using sh_vector.h / CVector in a SourceMod extension
 
Quote:

Originally Posted by PM (Post 1497959)
What is your #include order? Try including sh_vector.h later (in C++, NULL is not a language keyword, some header #defines NULL (0) or something like that).

Somehow sh_vector.h got put at the top, so yeah... anyway, I've changed the order now and it appears to be working.


All times are GMT -4. The time now is 05:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.