1

This might be a stupid question, but I really need to know since it's the first time I encounterd this:

    void function()
    {
    ;
    }

This is used in a thread based program with pthread. I want to know what it actually does. I tried looking it up, but I don't even know how to google it.

Thank you for your time.

Laura D
  • 66
  • 8
  • 2
    In short it does nothing.. Enter the function and exits .. Curious to know when this function is called – Gopi Apr 18 '15 at 10:59
  • It is used in the Dining Philosopers problem. It's called in the pthread method. And thank you for your answer :D – Laura D Apr 18 '15 at 11:01
  • But note that even if this function doesn't do anything the call to this has a stack overhead .. Since I don't see the whole code check why this is being called – Gopi Apr 18 '15 at 11:08
  • @Gopi: There is no such thing as a "stack" in C. Your statement seems highly speculative. If this function were called from within its translation unit, a decent compiler would probably not emit any code at all. – Kerrek SB Apr 18 '15 at 11:35
  • @KerrekSB Agree !! I had a thought that compiler will optimize this code out. Thanks for clarifying – Gopi Apr 18 '15 at 11:42

4 Answers4

3

It doesn't do anything. And the ; is superfluous.

Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
3

; is a C statement termination construct. Placing it without statement is meaningless and doesn't hurt in code behavior in anyways. In your case, function gets called and returns.

Prabhu
  • 3,443
  • 15
  • 26
1

it does nothing in its current form. maybe for future implementation.

lxg
  • 226
  • 3
  • 14
0

It does nothing. Most decent C compilers will most likely not even output code for a function like this. Where did you see this?

Daniel Rudy
  • 1,411
  • 12
  • 23