Language: C++

#include <bits/stdc++.h>
using namespace std;

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

#define F				first
#define S				second

int w, h, cnt = 0;

void solve( vector<vector<char>>& f, pair<int, int>& mp ) {

	if( mp.F - 1 >= 0 && f[mp.S][mp.F - 1] == '.' ) {
		cnt++;
		f[mp.S][mp.F - 1] = '#';
		solve( f, make_pair( mp.F - 1, mp.S ) );
	}
	if( mp.F + 1 < w && f[mp.S][mp.F + 1] == '.' ) {
		f[mp.S][mp.F + 1] = '#';
		cnt++;
		solve( f, make_pair( mp.F + 1, mp.S ) );
	}
	if( mp.S - 1 >= 0 && f[mp.S - 1][mp.F] == '.' ) {
		f[mp.S - 1][mp.F] = '#';
		cnt++;
		solve( f, make_pair( mp.F, mp.S - 1 ) );
	}
	if( mp.S + 1 < h && f[mp.S + 1][mp.F] == '.' ) {
		f[mp.S + 1][mp.F] = '#';
		cnt++;
		solve( f, make_pair( mp.F, mp.S + 1 ) );
	}
}

int main() {

	while( 1 ) {
		cin >> w >> h; if( w == 0 && h == 0 ) break;
		
		pair<int, int> mp;
		vector<vector<char>> f;
		vector<char> tmp( w );
		REP( i, h ) {
			REP( j, w ) {
				cin >> tmp[j];
				if( tmp[j] == '@' ) { 
					mp.first = j;
					mp.second = i; 
					tmp[j] = '#';
					cnt++;
				}
			}
			f.push_back( tmp );
		}
		solve( f, mp );
		cout << cnt << endl;
		cnt = 0;
	}
}


Compiler output:
a.cc: In function 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)':
a.cc:18:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
   18 |                 solve( f, make_pair( mp.F - 1, mp.S ) );
      |                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:13:54: note:   initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) {
      |                                      ~~~~~~~~~~~~~~~~^~
a.cc:23:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
   23 |                 solve( f, make_pair( mp.F + 1, mp.S ) );
      |                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:13:54: note:   initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) {
      |                                      ~~~~~~~~~~~~~~~~^~
a.cc:28:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
   28 |                 solve( f, make_pair( mp.F, mp.S - 1 ) );
      |                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:13:54: note:   initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) {
      |                                      ~~~~~~~~~~~~~~~~^~
a.cc:33:36: error: cannot bind non-const lvalue reference of type 'std::pair<int, int>&' to an rvalue of type 'std::pair<int, int>'
   33 |                 solve( f, make_pair( mp.F, mp.S + 1 ) );
      |                           ~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:13:54: note:   initializing argument 2 of 'void solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | void solve( vector<vector<char>>& f, pair<int, int>& mp ) {
      |                                      ~~~~~~~~~~~~~~~~^~