Your C++ compiler knows nothing about the GLSL shader language. You can't mix them like this.
If you want to define your shader in the code rather than in a separate file, you must put it in a string:
std::string shaderSource =
"uniform sampler2D texture;"
"uniform vec4 colorkey;"
""
"void main()"
"{"
" vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);"
" if (pixel == colorkey)"
" pixel.a = 0;"
" gl_FragColor = pixel;"
"}"
;
sf::Shader shader;
shader.loadFromMemory(shaderSource, sf::Shader::Fragment);
To create a .frag file, just create a simple text file and copy your shader code in it. There's no magic, shaders are really just text files, like C++ or any other language sources.