Plugin interface descriptions for TC 7.55 (beta)
Moderators: white, Hacker, petermad, Stefan2
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I will consider it - but I think that developpers should be clever enough to install the hlp viewer for Windows 7.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Agree.ghisler(Author) wrote:I will consider it - but I think that developpers should be clever enough to install the hlp viewer for Windows 7.
Christian,
I found an error in ContentDefaultParamStruct description (WDX API help):
typedef struct {
int size;
DWORD PluginInterfaceVersionLow;
DWORD PluginInterfaceVersionHi;
char DefaultIniName[MAX_PATH];
} ListDefaultParamStruct;
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Christian, it would be great to reflect details described here in API documentation (use MaxLen parameter name for string lengths, MaxChars for buffer sizes in characters, MaxBytes for buffer sizes in Bytes, and use const modifier for input only strings/buffers/structs).
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Unfortunately changing these headers would probably break almost all existing plugins...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Christian, no one tells to authors of existing plugins to use theese headers, they can still use their own old copies. But new ones will use correct headers.
And, only a few changes in code required - to add const modifiers for pointers that work with input (constant) strings/buffers (such buffers must not be written anyway).
Also, if function prototype differs from its declaration in CPP, compiler just ignores prototype (if function is not called from another CPP by including header with prototype). Even more, it is OK when variable names in prototypes and realization differ (compiler compares only types).
And, only a few changes in code required - to add const modifiers for pointers that work with input (constant) strings/buffers (such buffers must not be written anyway).
Also, if function prototype differs from its declaration in CPP, compiler just ignores prototype (if function is not called from another CPP by including header with prototype). Even more, it is OK when variable names in prototypes and realization differ (compiler compares only types).
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
For example, people who add Unicode support to their plugins will get the latest headers - but this will break their existing plugins if the parameters change.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
I doubt it will break anything. Adding Unicode requires a lot of changes anyway (all character types and strings should be converted, and Unicode strings should be called instead of old ANSI ones), so it won't be hard to add a pair of const's to code (if needed - and compiler will show all theese places, so no harm at all). As I said, no one should modify strings that I've marked as const - theese are read-only (input) strings, so there won't be any changes in logic. But it will simplify coding and improve code quality (it is a good rule to mark read-only parameters as const).
Nevertheless, as you wish.
Nevertheless, as you wish.
Christian, please add #ifndef ... #endif preprocessor checks for header files to prevent redefinitions in case of multiple includes (which often occur in projects with multiple include files):
For WcxHead.h:
Similar should be applied to other 3 header files (#ifndef _CONTPLUG_H_ for ContPlug.h, #ifndef _FSPLUGIN_H_ for FsPlugin.h and #ifndef _LISTPLUG_H_ for ListPlug.h). It is absolutely safe and won't break anything.
For WcxHead.h:
Code: Select all
#pragma once
#ifndef _WCHHEAD_H_
#define _WCHHEAD_H_
/* Contents of file wcxhead.h */
/* It contains definitions of error codes, flags and callbacks */
...
/* the rest of old wcxhead.h */
#endif // #ifndef _WCHHEAD_H_
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Hmm, I have never had this problem - when does this occur?
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
It is a usual problem of header files, that's why such pragma exists and all standard headers contain such #ifndef.
E.g. try to compile Multiarc plugin:
multiarc.h, ArchiverManager.h:
multiarc.cpp:
When compiler sees second definitions of same types (both multiarc.h and ArchiverManager.h include same wcxhead.h so preprocessor inserts same definitions into same source file more than once), it reports a bunch of errors.
E.g. try to compile Multiarc plugin:
multiarc.h, ArchiverManager.h:
Code: Select all
...
#include "wcxhead.h"
...
Code: Select all
...
#include "ArchiverManager.h"
...
#include "multiarc.h"
...
- ghisler(Author)
- Site Admin
- Posts: 48107
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I see - just don't include header files within header files.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
It is much easier to say than to do.
Good style tells not to define stuff that doesn't required in this source file, so there may be different header files that include some common header files (like Windows.h or WchHead.h). So it is better to have such protection in common header files.
In case of Multiarc it wasn't my fault/code so I simply added this protection to get rid of the problem.
Good style tells not to define stuff that doesn't required in this source file, so there may be different header files that include some common header files (like Windows.h or WchHead.h). So it is better to have such protection in common header files.
In case of Multiarc it wasn't my fault/code so I simply added this protection to get rid of the problem.