Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C order of operations -- foo() + bar() -- must foo be called before bar?

Tags:

c

In the following code:

int foo();
int bar();
int i;

i = foo() + bar();

Is it guaranteed by the C standard that foo is called before bar is called?

like image 837
David Schwartz Avatar asked Apr 27 '12 22:04

David Schwartz


People also ask

In which order will the functions FOO and bar be executed?

We can't predict the order of the functions foo & bar. These functions depends on ajax request to an api, so whichever ajax request completes first, it will call the corresponding function. Note: If you need to do synchronize both the functions together, then you can use a promise method.

What is FOO and bar in C?

In the world of computer programming, "foo" and "bar" are commonly used as generic examples of the names of files, users, programs, classes, hosts, etc. Thus, you will frequently encounter them in manual (man) pages, syntax descriptions, and other computer documentation.

What does FOO mean in C?

Foo (pronounced FOO) is a term used by programmers as a placeholder for a value that can change, depending on conditions or on information passed to the program. Foo and other words like it are formally known as metasyntactic variables.

What is FOO and bar in JS?

foo is an object of some kind, which you must have declared before using it. bar is the name of a function that is a member of the foo object. A simple example, var foo = { bar: function () { alert("Hello, World!" ); } }; // This displays an alert with the text "Hello, World!" foo.bar();


1 Answers

No, there's no sequence point with +. There's actually a quote on the Wikipedia page about it that answers your question:

Consider two functions f() and g(). In C and C++, the + operator is not associated with a sequence point, and therefore in the expression f()+g() it is possible that either f() or g() will be executed first.

http://en.wikipedia.org/wiki/Sequence_points

like image 182
Pubby Avatar answered Sep 28 '22 01:09

Pubby