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;

int 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 ) );
	}
	return cnt;
}

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 );
		}

		cout << solve( f, mp ) << endl;
		cnt = 0;
	}
}


Compiler output:
a.cc: In function 'int 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:53: note:   initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | int 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:53: note:   initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | int 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:53: note:   initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | int 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:53: note:   initializing argument 2 of 'int solve(std::vector<std::vector<char> >&, std::pair<int, int>&)'
   13 | int solve( vector<vector<char>>& f, pair<int, int>& mp ) {
      |                                     ~~~~~~~~~~~~~~~~^~