I am confused about this line of code:


this is the from the solana_program/macro.entrypoint

This macro emits the common boilerplate necessary to begin program execution, calling a provided function to process the program instruction supplied by the runtime and reporting its result to the runtime.

I do not understand what this statement means. Why do not projects that use anchor_lang package have that line of code?

1 Answer 1


This line, entrypoint!(process_instruction);, tells the compiler to begin program execution as we don't have a main function here as we have in simple rust program for example:

fn main() {
    println!("Hello, world!");

In anchor projects, it is handled by the following library. use anchor_lang::solana_program

In solana official docs it says:

Solana Rust programs may depend directly on each other in order to gain access to instruction helpers when making cross-program invocations. When doing so it's important to not pull in the dependent program's entrypoint symbols because they may conflict with the program's own. To avoid this, programs should define an no-entrypoint feature in Cargo.toml and use to exclude the entrypoint.

Then when other programs include this program as a dependency, they should do so using the no-entrypoint feature.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.