co-worker
co-worker

Reputation: 213

C++: error: expected primary-expression

void add(int register, int& acc)
{
    acc += register;
}

main.cpp:124: error: expected primary-expression before ‘register’

wth is wrong right there?

Upvotes: 2

Views: 803

Answers (2)

Steve Townsend
Steve Townsend

Reputation: 54178

register is a C++ keyword, rename this to something else. It's used to qualify variables as a hint to the compiler to optimize the variable's storage directly to a CPU register rather than RAM - see here.

Upvotes: 4

The Archetypal Paul
The Archetypal Paul

Reputation: 41779

"register" is a keyword in C++ (a hangover from C days, mostly)

Upvotes: 8

Related Questions