You can only select an enemy unit as a target if your unit can see it, or at least part of it. Obviously a unit cannot open fire if there is a hill, building, or some other large object in the way.
Sometimes it may be hard to tell if a line of sight is blocked or not, so players must stoop over the table for a 'model's eye view'. This is the best way to see if a line of sight exists.
Models in the attacking unit do not block a line of sight (they duck, crouch or get out of the way). Likewise ignore units from your own side (your unit conducts its firing at a convenient moment when their compatriots are not in the way). Enemy models and all vehicles, friend or foe, do block a unit's line of sight if they are in the way, just like buildings and other terrain. Enemy models will block the line of sight to other models up to twice their height.
Diagram: Line of Sight — a top-down battlefield showing a Space Marine Land Speeder in the open with Dark Eldar warriors positioned around a patch of woodland. The Dark Eldar can see and shoot at the Land Speeder, but the Space Marine squad, hidden behind the woodland, is out of line of sight of the Dark Eldar.
Diagram: Partial Line of Sight — Dark Eldar warriors and a Whirlwind tank sit behind a rock formation that casts a shaded "no line of sight" zone. Models inside the shaded area have no line of sight to the Dark Eldar and cannot shoot. All the models outside the shaded area can see at least one of the Dark Eldar and so can shoot at them.
Individual models in the unit that don't have a line of sight to the target unit cannot fire, and any models in the target unit that cannot be seen by their attackers cannot be hit by their firing.