Compiling AMXX Module
I'm trying to compile my module, but I'm seeing the below error messages. I have not modified this section within the amxxmodule header or source, so I'm confused on why it is occurring. Commenting out the typedefs causes a significant number of errors to appear similar to:
Code:
1>d:\projects\cpp\logger\public\sdk\amxxmodule.h(155): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Thank you for any help! The source code for my project is located: https://github.com/collinsmith/LoggerModule I've been using VS 2015 Community Edition Code:
1>------ Rebuild All started: Project: logger, Configuration: Debug Win32 ------ |
Re: Compiling AMXX Module
I was able to resolve the above issue by adding the following to my cpp file:
Code:
#define HAVE_STDINT_H Code:
1>------ Rebuild All started: Project: logger, Configuration: Release Win32 ------ |
Re: Compiling AMXX Module
1 Attachment(s)
It's because HAVE_STDINT_H needs to be declared globally. You should define it in the VS project options.
Here the updated project files + few minor changes like cleaning your includes, using some ke:: You might need to adjust the Additional Includes Directories in C/C++ -> General ; since it's based on AMXX structures (probably just removing "/metamod") |
Re: Compiling AMXX Module
Quote:
I started copying over many of the settings that AMXX was using in its project. |
Re: Compiling AMXX Module
Something that has really helped me is looking at what over people have done. For instance, your own modules and looking at how the AMXX modules are built. It's just a bit tricky to get the initial configuration, but I guess that's expected for a newbie. :D
At some point I may trash the current code base and start from scratch, because I've learned a heck of a lot already, and I know there are a ton of things done incorrectly, or badly. |
Re: Compiling AMXX Module
I'm running into a problem trying to express something that's beyond my basic knowledge of C++.
For my module I would like to add custom message formatting to maximize flexibility and the expressability of the logger. E.g., every argument will have custom message formatting (will not support modifiers like "%-5s", and this is not meant to support any other specifiers than listed below [i.e., default C++ specifiers]): Code:
%d current date Code:
"%n_%d" Code:
"[%s] [%t] %n::%f - %l" Code:
"%s_%n_%d" So, e.g., if a message was formatted as "[%s] [%t] %n::%f - %l", when the constructor is called, this is compiled into "[%s] [%s] %s::%s - %s", with a stack representing {SEVERITY, TIME, PLUGIN_NAME, CALLING_FUNCTION, LOG_MESSAGE}, which would then format the fprintf call like: Code:
fprintf(pF, "[%s] [%s] %s::%s - %s", SEVERITY, TIME, PLUGIN_NAME, CALLING_FUNCTION, LOG_MESSAGE); Code:
char time[16]; My current idea is to pre-format the message in another function of my creation before passing into fprintf, so essentially calling fprint. So my custom function would handle the dynamic parameters. source I'll be looking into this more, trying to find a solution, and post an update here if I do. If anyone has any ideas, I would appreciate hearing them. Currently I have: https://github.com/collinsmith/Logge...r.cpp#L77-L162 https://github.com/collinsmith/Logge...r.cpp#L190-197 Edit: I think I'm closer now, however the module hangs because of a bad pointer. I'll try and look into it later. |
Re: Compiling AMXX Module
I made a lot of progress. I decided to use a static array of up to 16 arguments (should be more than enough, but I might still change this to a vector for infinitely many arguments). I chose to take the route to do formatting one argument at a time, e.g.:
Code:
for each argument in array: Code:
|
Re: Compiling AMXX Module
1 Attachment(s)
I was able to successfully implement my idea. The code started getting a bit ugly because I didn't write any new functions to assist with the copying, but it works. Next step is to clean up what I've done and add two remaining features:
1) get calling function name (so in the logs one could have plugin::function, like in C) 2) add option to print stack trace following the message (this will be default for WARN and ERROR severities) The idea is to have format similar to Java (so this format may be fixed, however that is not out of the question to change): Code:
exception in thread "main" java.lang.NullPointerException Code:
[ERROR] [21:54:38] [plugin1.sma::function1] Reason: Invalid handle specified (4) Code:
new Logger:logger = LoggerCreate( |
Re: Compiling AMXX Module
I cleaned up the algorithm a lot to remove formatted C strings. This should greatly increase the overall speed, and allowed for me to remove some unnecessary complexities (e.g., caching argument order and replacing arguments with %s, now the logger format string is left as-is). If it becomes a priority later I can modify the algorithm to include some of the basics:
Code:
%-#.#<specifier> Now for the other couple of features. BTW: Does anyone know if there is an algorithm in C std library to copy single char into first cell of string? I wrote this guy because I couldn't find one: Code:
char* strncpyc(char* destination, const char source, int len) { |
Re: Compiling AMXX Module
I was able to implement printf-like specifiers. The logic was a bit complicated, but assuming there aren't any bugs, it should be very efficient.
Code:
[%5s] [%-6.4t] %n::%f %l |
All times are GMT -4. The time now is 10:32. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.