I discovered recently, nearestBuilding doesn't work for edited buildings (all maps) or the embedded houses on Unsung map. I don't know the behavior with the other modded maps.
So, I had to write:
_building = nearestObject [_unit,"house"];
_building = nearestBuilding _unit;
And this helped by the fact a wall isn't a house but a building, so you don't want to spawn something at every walls!. Small objects like small transmission tower (looking like a pole) remains houses (and buildings of course)...