This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Hi all, due to some problems I've had with compiling a plugin I stumbled upon __TFS_H__ in tfs.h while tracing the error. What does it do and what happens if I do something like this TFS(&tfs_set_notset) somewhere else in the code?

Thanks. Mike

asked 14 Apr '16, 01:05

mikethebo's gravatar image

mikethebo
21447
accept rate: 0%

edited 14 Apr '16, 01:06


What does it do

It makes sure that, if a Wireshark source file includes both tfs.h and some other header file that includes tfs.h, the header file's contents are processed only once, so you don't, for example, get warnings or errors from redefinitions or redeclaration.

This is a VERY common technique in C header files; you'll probably find at least one header file for the OS or compiler you're using that has a "header guard" of that type.

what happens if I do something like this TFS(&tfs_set_notset) somewhere else in the code?

It works, if you do that in the right place (a definition of a named packet field) and if you've included either tfs.h or some header file that includes tfs.h before you use TFS(&tfs_set_notset).

permanent link

answered 14 Apr '16, 01:54

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

Although as noted elsewhere, on Windows, there appear to be issues including pre-defined tfs values from libwireshark in a plugin.

(14 Apr '16, 02:12) grahamb ♦
1

From proto.h

/** Make a const true_false_string[] look like a _true_false_string pointer, used to set header_field_info.strings */
#define TFS(x)  (const struct true_false_string*)(x)

The declarations in tfs.h are just handy, pre-canned true_false strings, which, on Windows, can't unfortunately be use in plugins. You can just define those strings yourself (as in tfs.c) if you need any of them.

(14 Apr '16, 03:11) grahamb ♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×13
×11
×4

question asked: 14 Apr '16, 01:05

question was seen: 987 times

last updated: 14 Apr '16, 12:14

p​o​w​e​r​e​d by O​S​Q​A