0

I'm trying to embed a file (OpenCL kernel) as char array the main problem is that it gives me errors for any line containing #

example:

char mykernel[] =
"stuff ---"
"#if(1)"
"    stuff"
"#else"
"    another stuff"
"#define ASD 15";

void* clh = clsopen(cp,mykernel,CLLD_NOW);

all these things are giving me bad errors (compiler errors as if it can't see them)

Edit: semicolon was a mistake in posting question.

Errors are like:

#define ASD 15

use this ASD in the whole code, get errors like undeclared identifier

use #if #else

use some function in #if and same name in #else

get errors like the function is declared 2 times with the same name...and so on

edit2:

"#if(1)" //char number 26123: error: note: previous definition is here
"    inline functionA ...with output A"
"#else" //char number 28700: error: redefinition of functionA
"    inline functionA ...with output B"
3
  • 3
    There's a missing semicolon. It would help if we knew what the error was. Commented Mar 12, 2013 at 21:35
  • 1
    Maybe you need to add \n before #define? Commented Mar 12, 2013 at 21:46
  • @ qehgt : wow though this is a simple note but it worked :D Commented Mar 12, 2013 at 21:54

1 Answer 1

1

All of the lines starting with # are also lines that start without any leading whitespace. The problem is that in a natural source file, each line will end with \n which the compiler treats as whitespace. Add the \n to the end of every line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.