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

enum struct member variable size


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 01-07-2019 , 19:48   enum struct member variable size
Reply With Quote #1

PHP Code:
#define MAX_PRESET_NAME_LENGTH 100
#define MAX_TABLE_NAME_LENGTH 100

enum struct PlayerTableIdentifier
{
    
int dbPresetName[MAX_PRESET_NAME_LENGTH];
    
char tableName[MAX_TABLE_NAME_LENGTH];
}

enum struct PlayerTable
{
    
PlayerTableIdentifier pTableIdentifier;
    
int client;
}

public 
void OnPluginStart(){

    
PlayerTable test;
    
Format(test.pTableIdentifier.dbPresetNamesizeof(test.pTableIdentifier.dbPresetName), "test");
    
Format(test.pTableIdentifier.tableNameMAX_TABLE_NAME_LENGTH"test");
    
test.client 2;

I expected this to be compiled flawlessly but

sizeof(test.pTableIdentifier.dbPresetName)

this expression occurs error. I doubt i made a mistake.
__________________
Starbish is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 01-07-2019 , 21:23   Re: enum struct member variable size
Reply With Quote #2

PHP Code:
#define MAX_PRESET_NAME_LENGTH 100
#define MAX_TABLE_NAME_LENGTH 100

enum struct PlayerTableIdentifier
{
    
int dbPresetName[MAX_PRESET_NAME_LENGTH];
    
char tableName[MAX_TABLE_NAME_LENGTH];
}

enum struct PlayerTable
{
    
PlayerTableIdentifier pTableIdentifier;
    
char abc[300];
    
int client;
}

public 
void OnPluginStart(){

    
PlayerTable test;
    
Format(test.abcsizeof(test.abc), "test");
    
Format(test.pTableIdentifier.dbPresetNamesizeof(test.pTableIdentifier.dbPresetName), "test");
    
Format(test.pTableIdentifier.tableNameMAX_TABLE_NAME_LENGTH"test");
    
test.client 2;

Looks like enum struct inside of enum struct is a problem?

the size of PlayerTable.abc can be retrieved..
__________________
Starbish is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-08-2019 , 06:07   Re: enum struct member variable size
Reply With Quote #3

When you get an error and ask for help, you should post the error message as well. Help others help you.

But you can probably do
PHP Code:
sizeof(PlayerTableIdentifier::dbPresetName
__________________

Last edited by klippy; 01-08-2019 at 06:33.
klippy is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 01-08-2019 , 13:14   Re: enum struct member variable size
Reply With Quote #4

Quote:
Originally Posted by KliPPy View Post
When you get an error and ask for help, you should post the error message as well. Help others help you.

But you can probably do
PHP Code:
sizeof(PlayerTableIdentifier::dbPresetName
Thank you
__________________
Starbish is offline
Reply



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 21:55.


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