Preheat the oven to 350°F (175°C). Grease and flour two 9-inch round cake pans.
In a large mixing bowl, combine the flour, sugar, baking powder, baking soda, cinnamon, and salt.
In another bowl, whisk together the vegetable oil, eggs, and vanilla extract until well combined.
Gradually add the wet ingredients to the dry ingredients, mixing until just combined.
Fold in the grated carrots, crushed pineapple, and chopped walnuts (if using).
Divide the batter evenly between the prepared cake pans.
Bake in the preheated oven for 30-35 minutes, or until a toothpick inserted into the center comes out clean.
Allow the cakes to cool in the pans for 10 minutes, then remove from the pans and transfer to a wire rack to cool completely.
Frost with cream cheese frosting if desired, and enjoy!