mirror of
https://github.com/ADD-SP/ngx_waf.git
synced 2026-04-26 14:05:52 +03:00
[GH-ISSUE #54] move code from *.h to *.c #170
Labels
No labels
MacOS
Nginx
OpenResty
Tengine
bug
documentation
enhancement
needs-investigation
pull-request
question
stale
stale
stale
timeout
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ngx_waf#170
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @RekGRpth on GitHub (Jul 22, 2021).
Original GitHub issue: https://github.com/ADD-SP/ngx_waf/issues/54
please, move all code from *.h to *.c
@ADD-SP commented on GitHub (Jul 22, 2021):
Do you mean rename all
*.hto*c? I don't know why you would want to do that.If you mean splitting the headers into
.hand.c, then from a software engineering point of view we should do that, but it will cause more warnings and errors when the module is compiled.To avoid conflicts with other modules or with nginx's own symbols, we develop modules by declaring functions as
static, so that symbols inside a source file are not exposed to the outside unless the#includedirective is used, and so that symbol conflicts can occur during compilation and linking.If the declaration is written in
*.hand the implementation is written in*.c. then an error will occur at compile time because of the undefined symbols. So I have to put both in one file.But if you have a way to solve this problem, please advise.
@RekGRpth commented on GitHub (Jul 22, 2021):
Yes, declarations should be in *.h and implementation in *.c
To avoid errors You should does not make static functions that used in many *.c, i.e. if some function is used only in current *.c file then it shuld be static, else - not
@RekGRpth commented on GitHub (Jul 22, 2021):
Consider static functions as private method and non-static functions as public ones.
And add prefix to all Your public functions with Your unique prefix like ngx_http_waf_ and their names does not conflict with others.
@ADD-SP commented on GitHub (Jul 22, 2021):
I actually considered this way before, but I felt that the code would become more difficult to read (although it is already difficult to read), so I have put it off until now.
@RekGRpth commented on GitHub (Jul 22, 2021):
https://github.com/ADD-SP/ngx_waf is compiled as single *.c file
I found only one project that do so https://github.com/wandenberg/nginx-push-stream-module
but other projects put declarations in *.h and implementation in *.c like https://github.com/nbs-system/naxsi
@ADD-SP commented on GitHub (Jul 22, 2021):
I should not have put this off for so long and I will address it in the near future.
@ADD-SP commented on GitHub (Jul 23, 2021):
Done on branch dev.
@RekGRpth commented on GitHub (Jul 23, 2021):
thanx, but it does not comile until fix
@ADD-SP commented on GitHub (Jul 23, 2021):
Done.
github.com/ADD-SP/ngx_waf@0763c32f86/inc/ngx_http_waf_module_config.h (L12-L22)@RekGRpth commented on GitHub (Jul 23, 2021):
thanx, now it compiles!