Question: Since I am not so great programming in PHP I wanted to ask my question here, hopefully you guys can help me out.

I'm building a WordPress website, this website has a custom page template like `custom-single.php`.

On that custom template I want to show posts filtered on a tag. And the tag is coming from a Angular value like so `{{ctrl.name.tagname}}` and yes ofcourse I've made a tag as well in WordPress.

The code must show max 5 posts (fully with title and ofcourse the content), after the posts it must show max 5 items which are older then 5 posts before, but then only with title using a bullet-list.

Answer: 
Clang uses a cost based decision whether a function will be inlined or not. This cost is affected by a lot of things. It is affected by `static`.

Fortunately, clang has an output, where we can observe this. Check out this godbolt [link](https://godbolt.org/z/6gqxGs):

```
void call();

inline void a() {
    call();
}

static inline void b() {
    call();
}

void foo() {
    a();
    b();
}

```

In this little example, `a()` and `b()` are the same, the only exception is that `b()` is static.

If you move the mouse over the calls `a()` or `b()` on godbolt (in `OptViewer` window), you can read:

`a()`: cost=0, threshold=487

`b()`: cost=-15000, threshold=487

(clang will inline a call, if the cost is less than the threshold.)

clang gave `b()` a much lower cost, because it is static. It seems that clang will only give this -15000 cost reduction for a static function only once. If `b()` is called several times, the cost of all `b()`s will be zero, except one.

Here are the numbers for your case, [link](https://godbolt.org/z/NAQ4cm):

`process_value():` cost=400, threshold=325 -> it is just above the threshold, won't be inlined

`process_valueS():`: cost=-14600, threshold=325 -> OK to inline

So, apparently, `static` can have a lot of impact, if it is only called once. Which makes sense, because inlining a static function once doesn't increase code size.

Tip: if you want to force clang to inline a function, use `__attribute__((always_inline))` on it.
`inline` is just an advise to the compiler, which may or may not really inline that your particular code.

Regarding to the `static` keyword, if it's applied to a global variable, then it has the file-scope (as you've mentioned) if you compile your code as a separate compilation-unit. So it's even possible to have your static global variables accessible from other files if you compile them as a single compilation unit. This means that in reality, the scope of the global static variables is not the file but the compilation unit (which may or may not be one single file).

But, since you have a global static function, not a variable, it is accessible from everywhere as a global static function.

**EDIT:**
As suggested by @Peter Cordes in comments below, it may be a real mess with inline and static at the same time, so the official doc ( <https://en.cppreference.com/w/cpp/language/inline> ) says that the redefinition of inline functions (and variables since C++17) must be non-static.