Raised This Month: $12 Target: $400
 3% 

Using sh_vector.h / CVector in a SourceMod extension


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-24-2011 , 16:43   Using sh_vector.h / CVector in a SourceMod extension
Reply With Quote #1

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?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 06-24-2011 at 16:49.
Powerlord is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-24-2011 , 17:34   Re: Using sh_vector.h / CVector in a SourceMod extension
Reply With Quote #2

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
__________________
hello, i am pm
PM is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-27-2011 , 13:19   Re: Using sh_vector.h / CVector in a SourceMod extension
Reply With Quote #3

Quote:
Originally Posted by PM View Post
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
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-27-2011 , 13:39   Re: Using sh_vector.h / CVector in a SourceMod extension
Reply With Quote #4

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).
__________________
hello, i am pm
PM is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-27-2011 , 13:41   Re: Using sh_vector.h / CVector in a SourceMod extension
Reply With Quote #5

Quote:
Originally Posted by PM View Post
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.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:37.


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